Question about scope in a class

I am in question of how scopes work in a class.

For example:

1
2
3
4
5
6
7
8
9
  class MyClass{
  int V1;
  public:
     ... Something ...

  private:
     ... Something ...

};


In which scope is int V1; in this case?
That is just the definition of a class. No objects, nor scopes as we know them.
> In which scope is int V1; in this case?

Class scope. http://eel.is/c++draft/basic.scope.class

Specifically, the name of the member V1 can be used directly in the scope of the class MyClass
or in the scope of a class directly or indirectly derived from MyClass

Outside the class scope, it may be used only
after the . operator applied to an expression of the type of its class or a class derived from its class,

after the -> operator applied to a pointer to an object of its class or a class derived from its class,

after the ​::​ scope resolution operator applied to the name of its class or a class derived from its class.

I guess that author asked about would it be public or private. In this case V1 will be private.
Topic archived. No new replies allowed.