dimanche 9 janvier 2022

Is a declaration for a non-static data member of a class type also a definition?

I am learning C++. In particular, the difference between declaration and definition. To my current understanding

All definitions are declarations but not all declarations are definitions.

Here is an example of what I currently know.

int x; //definition(as well as declaration according to the above quote)
extern int y; //declaration that is not a definition 

class CustomType
{
    int x; //is this a "declaration that is not a definition" OR a "definition"
};
int main()
{
   int p[10]; //definition
   //...
}

I want to know whether int x; inside the class' definition is a declaration that is not a definition or a definition. And where in the standard is this stated so that I can read more about it.

Aucun commentaire:

Enregistrer un commentaire