2

I have seen many questions regarding definition and declaration of global and local variables and static members, but for non-static member variables, I am unable to distinguish it.

In the code below

class Line 
{
int length; //?
static int L;  //declared
}; //defined

We have defined the class Line, we have declared its static member L. So what about the non-static member length? Is it defined or declared?

sir_osthara
  • 154
  • 2
  • 9

1 Answers1

1

For normal (automatic, non-static) variables, like length in your code, declaration without the extern keyword is also definition. So length is both declared and defined.

Violet Giraffe
  • 29,070
  • 38
  • 172
  • 299