Is it possible to specifiy a template as a member but not know all the details? Or rather how can I work around this.
Example doesn’t work but might show you what I’m trying to achieve.
template<typename T>
struct Foo {
///blah...
};
struct Bar {
Foo* m_foo;
};
Bar in this case is a base class, and depending on the derived classes I wont know the full details of Foo
You can either make
Bara template class as well so it can pass that template argument along toFoo, or else you can make all theFoo<T>variations inherit from a common interface (in C++, an interface is just an abstract class with no implementation, all members are pure virtual functions) and thenBarcan point to that interface.The first way is better if
Baris just going to provide some functionality which will be reused by a bunch of derived classes.The second way is better if descendants of
Barare going to be used polymorphically.