A
A. Saksena
Hi all,
Why this code does't work!!
========================
#include <iostream>
template<typename T>
class a
{
public:
typedef T var;
};
class b
{
};
template<typename T>
void connect(typename a<T>::var& v1,typename a<T>::var& v2){}
int main()
{
a<b>::var v1,v2;
connect(v1,v2);
}
=======================
During compilation with gcc(3.2.3) I get following error:-
$ g++ problem.cpp
problem.cpp: In function `int main()':
problem.cpp:19: no matching function for call to `connect(b&, b&)'
I would expect to template function connect(b&, b&) to exist.
If this is not legal c++. Is there is way way to implement suct a
functionality?
Abhishek
Why this code does't work!!
========================
#include <iostream>
template<typename T>
class a
{
public:
typedef T var;
};
class b
{
};
template<typename T>
void connect(typename a<T>::var& v1,typename a<T>::var& v2){}
int main()
{
a<b>::var v1,v2;
connect(v1,v2);
}
=======================
During compilation with gcc(3.2.3) I get following error:-
$ g++ problem.cpp
problem.cpp: In function `int main()':
problem.cpp:19: no matching function for call to `connect(b&, b&)'
I would expect to template function connect(b&, b&) to exist.
If this is not legal c++. Is there is way way to implement suct a
functionality?
Abhishek