partial template specialization error...

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>();
}
 
V

Victor Bazarov

Fei said:
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>(){

Drop the said:
cout << "3" << endl;
}

int main(){
C<int> c;
c.display<int>();
}

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top