Thread View: gnu.g++
1 messages
1 total messages
Started by Stefan Ratschan
Wed, 23 Aug 1995 13:49
Cannot use templates with nested classes in G++ 2.7.0
Author: Stefan Ratschan
Date: Wed, 23 Aug 1995 13:49
Date: Wed, 23 Aug 1995 13:49
38 lines
1320 bytes
1320 bytes
When I try to compile the following code with G++ 2.7.0, I get an error
message:
---
template <class T> class X {
public:
class A {
};
X<T>::A GetAttr(void);
private:
X::A attr;
};
template <class T> void X<T>::A X<T>::GetAttr(void) {
return attr;
};
---
test.cc:10: parse error before `<'
It seems that G++ can refer to nested classes only inside of the envelope
class, because the following works:
template <class T> class X {
public:
class A {
};
X<T>::A GetAttr(void) { return attr; };
private:
X::A attr;
};
However I would like to define the function out of the class declaration.
Is this a problem of C++ or of the G++ compiler?
Is there any different solution that works?
Or did I just use the wrong syntax?
Stefan Ratschan
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads