vendredi 3 mars 2017

C++ - the "using" keyword clarification

I need some quick clarification about the using keyword regarding classes since I'm not sure I understand it correctly.

Let's say I hate the following example:

class B {
public:
    int var;
    int f(void);

};

class C : B {protected: using B::var; };

Does that mean that instead of inhering the variable "var" as public from class B, class C instead inherits this variable as protected and the only public variable left will be the int f(void);?

Also, could the class C inherit the variable as private by having private: using B::var; inside it's body?

And is there any point of writing public: using B::var; since the variable var is already public inside class B?

Thanks!

Aucun commentaire:

Enregistrer un commentaire