I don't understand the following code:
template <int _id> class Model;
template <int _id> class Model : public Model<0> { ... };
So, class Model derives from itself it seems. This doesn't compile with EDG or Gcc (error: invalid use of incomplete type ‘class Model<0>’), but Visual Studio accepts it. What compiler is right and for what reason?
So, class Model derives from itself it seems.
The class doesn't inherit itself. Every instatiation of Model<N> is a different, unrelated class.
This doesn't compile with EDG or Gcc (error: invalid use of incomplete type ‘class Model<0>’), but Visual Studio accepts it. What compiler is right and for what reason?
GCC is correct, at the point of usage, Model<0> is incomplete. Inheritance requires a complete class declaration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With