Use a Using-Declaration Instead of an Access Declaration

The access specifier of a base class member can be changed in a derived class by an access declaration, as in this example:

 class A{public:  int n; };class D : public A{private:   A::n; // access declaration changes access of A::n to private; deprecated};

According the ANSI/ISO Standard, the use of access declarations is considered deprecated. Instead, you should use a using declaration for that purpose:

 class D : public A // using-declaration version{private:   using A::n; // using declaration changes the access of A::n to private};
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: