F
Fei Liu
The attached sample code generates this error. Is there any way to
define the function outside the class definition body? Thanks,
#include <iostream>
using namespace std;
template <typename T>
class C{
public:
template <typename U>
void display();
};
template <typename T>
template <typename U>
void C<T>::display<U>(){
cout << "3" << endl;
}
int main(){
C<int> c;
c.display<int>();
}
define the function outside the class definition body? Thanks,
#include <iostream>
using namespace std;
template <typename T>
class C{
public:
template <typename U>
void display();
};
template <typename T>
template <typename U>
void C<T>::display<U>(){
cout << "3" << endl;
}
int main(){
C<int> c;
c.display<int>();
}