nested class in a templated class

I have the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
template<typename T> class Outer
{
private:
    enum Type { one, two, three };
    class Inner
    {
    public:
        void setType( Type type );
        Type getType() const;
    private:
        Type _type;
    }
}

template<typename T>
void Outer<T>::Inner::setType( Type type )
{
    _type = type;
}

template<typename T>
Outer<T>::Type Outer<T>::Inner::getType() const
{
    return _type;
}


This causes the compiler to bark at the definition of the getType function ( line 22 ). It works just fine for the setType, or any other function with a void return type, but trying to return anything else, even a primitive, results in a compilation error.
What's wrong with it?
hmm....

I don't actually use template

what am I using is typedef

I'll work on that later
When in doubt, try throwing the typename keyword before templated types.

1
2
template<typename T>
typename Outer<T>::Type Outer<T>::Inner::getType() const



EDIT:

if you're interested:

http://www.parashift.com/c++-faq-lite/templates.html#faq-35.18
Last edited on
typename did the trick. Thanks!
Topic archived. No new replies allowed.