Kenny
Kenny

Reputation: 3

Nested Classes with Template

I'm having issues using a nested class with a template. The first snippet is provided, I just have to implement it.

 template <typename T>
class a {
   public:
      class b {
         public:
            func(); 

I thought the implementation would look something like this, but it isn't working.

    template<typename T>
    a<T>::b<T>::func(){}

Upvotes: 0

Views: 44

Answers (1)

Ted Lyngmo
Ted Lyngmo

Reputation: 118077

There's not much wrong with your start. You just need to to tie it together.

template <typename T>
class a {
public:
    class b {
    public:
        void func();  // return type missing
    }; // missing
}; // missing

template <typename T>
void a<T>::b ::func() {}
//          ^ not <T>

Demo

Upvotes: 3

Related Questions