J
Jahagirdar Vijayvithal S
I am trying to compile the code below but get an error of
/tmp/a.cpp: In function `int main()':
/tmp/a.cpp:15: no matching function for call to `a<int>::foo(const
char[4])'
----------------Start code-------------------------
template <class T>
class a {
T var;
public:
template<class U> a<U>* foo(char *name);
};
int main()
{
a<int> aa;
aa.foo("jvs");
}
template<class T> template<class U> a<U>* a<T>::foo(char *name) {
///Some processing on "name"
return (U*)0;
}
----------------End code-------------------------
The Intent of the code is to return an object of type a<U> after
processing the string name.
Any pointers on what I am doing wrong and the meaning of the error
message?
reposted by jvs for girish
Regards
Jahagirdar Vijayvithal S
/tmp/a.cpp: In function `int main()':
/tmp/a.cpp:15: no matching function for call to `a<int>::foo(const
char[4])'
----------------Start code-------------------------
template <class T>
class a {
T var;
public:
template<class U> a<U>* foo(char *name);
};
int main()
{
a<int> aa;
aa.foo("jvs");
}
template<class T> template<class U> a<U>* a<T>::foo(char *name) {
///Some processing on "name"
return (U*)0;
}
----------------End code-------------------------
The Intent of the code is to return an object of type a<U> after
processing the string name.
Any pointers on what I am doing wrong and the meaning of the error
message?
reposted by jvs for girish
Regards
Jahagirdar Vijayvithal S