I have a quick question about class declaration vs. class definition.
So, I can think of four different scenarios of class code:
Which ones qualify as declarations and which as definitions? Why?
TIA.
1)
class foo_empty{};
2,3)
class foo_NoMemDef{
int f1(); //Member function declaration(?), no body
//int i; (consider including this as a separate case 3)
};
4)
class foo_final{
int f2(){}
};
Which ones qualify as declarations and which as definitions?
All examples show class definitions (that are also declarations). A class declaration that is not a definition looks like this:
class Foo;
Once you "open/close" a class by { and }, you are providing a definition.
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