1234 5678
1234 5678

Reputation: 23

How do I use the scope resolution operator for a nested class inside a template class?

template <typename T>
    class School{
     public:
    class Student{
     public:
     Student & operator++();
     Student operator++(int);
               
}
}

Assuming I have this in my header file, how would I use the scope resolution operator to for an hpp file? I have tried this but the result were an expected initializer before & token

template <class T>
T School<T> :: Student& Student:: operator++()
{

}

Upvotes: 2

Views: 139

Answers (1)

Sam Varshavchik
Sam Varshavchik

Reputation: 118445

One more, for the win (with a pinch-hit from typename):

template <class T>
typename School<T>::Student &School<T>::Student::operator++()
{
    return *this;
}

Upvotes: 3

Related Questions