Return pointer to nested inner class from generic outer class
- by helixed
I'm new to C++, so bear with me. I have a generic class called A. A has a nested class called B. A contains a method called getB(), which is supposed to return a new instance of B. However, I can't get my code to compile. Here's what it looks like:#include
A.h
template <class E>
class A {
public:
class B {
public:
int data;
};
B * getB();
};
A.cpp
#include "A.h"
template <class E>
A<E>::B * A::getB() {
return new B();
}
When I try to compile this, I get the following error:
error: expected constructor, destructor, or type conversion before '*' token
Does anybody know what I'm doing wrong?
Thanks,
helixed