N
newbie
Thanks for helping on this problem
suppose I have the following class
class MyContent {
vector<MyType1> v1;
vector<MyType2> v2;
}
And I have a templated function
template <class Type> foo(vector<Tpye>& a, int type_code, MyContent&
content) {
if(type_code) {
//insert elements in 'a' into content.v1
for(int i = 0; i < a.size(); i++)
content.v1.push_back(a);
} else {
// insert elements in 'a' into content.v2
for(int i = 0; i < a.size(); i++)
content.v2.push_back(a);
}
}
But the compiler complains unmatched type!! How can I solve it?
suppose I have the following class
class MyContent {
vector<MyType1> v1;
vector<MyType2> v2;
}
And I have a templated function
template <class Type> foo(vector<Tpye>& a, int type_code, MyContent&
content) {
if(type_code) {
//insert elements in 'a' into content.v1
for(int i = 0; i < a.size(); i++)
content.v1.push_back(a);
} else {
// insert elements in 'a' into content.v2
for(int i = 0; i < a.size(); i++)
content.v2.push_back(a);
}
}
But the compiler complains unmatched type!! How can I solve it?