Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Intermediate
May 5, 1999

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
};
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date