class inside templated class

I

icksa1

Hi:
I have a templated class, inside of which I declared another class, as
shown below:

template <class T, int n> class array
{
class subclass
{

};

};

When I try to declare a function that uses subclass as a return value I
get an error. For example:

template <class T, int n>
array<T,n>::subclass function()
{

}

int main()
{
return 0;
}

gives the following error:
main.cpp:4: error: expected constructor, destructor, or type conversion
before 'function'

Im using g++.

Any suggestions?
Thanks
 
K

Kai-Uwe Bux

Hi:
I have a templated class, inside of which I declared another class, as
shown below:

template <class T, int n> class array
{
class subclass
{

};

};

When I try to declare a function that uses subclass as a return value I
get an error. For example:

template <class T, int n>
array<T,n>::subclass function()

make that:

typename array said:
{

}

int main()
{
return 0;
}

Best

Kai-Uwe Bux
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top