Template error...


Imagine the following class template:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

template <typename T>
class C {
public:
    struct S {

    };

    S return_s();
};


template<typename T>
C<T>::S C<T>::return_s() {}



If i try to compile this it will return:
expected constructor, destructor, or type conversion before "C"

What do you recommend in order to deal with this situation? of course that it can be done if i implement the function inside the class, but i cant implement it outside...
1
2
3
4
5
6
7
8
9
10
11
12
13
template <typename T>
class C {
public:
    struct S {

    };

    S return_s();
};


template<typename T>
typename C<T>::S C<T>::return_s() {}
Thank you very much. So, typename keyword ensures that C<T>::S is a type right? so it won't be an ambiguous declaration to the compiler...
Topic archived. No new replies allowed.