Is the following valid? Or how can I get something close to this.
template<class T_> class Template {
//something
};
class Parent {
public:
Template<Parent> variable;
Parent() : variable(this) { }
};
class Derived : public Parent {
public:
Template<Derived> variable;
Derived() : Parent() { }
}
Thanks in advance.
It’s technically “valid” in that your compiler has to accept it (it may warn you, and IMHO it should), but it doesn’t do what you think it does: Derived’s
variableis separate fromParent‘s, and is not getting explicitly initialized (so it uses the default ctor forTemplate<>).