devxlogo

Use a Using-Declaration Instead of an Access Declaration

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};
See also  How HealthStream Learning Center Supports Healthcare Education and Compliance
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist