answersLogoWhite

0

The only way that private attributes of a base class can be accessed by a derived class (protected or public) is through a protected or public method in the base class.

The protected or public method is the interface through which access to the attributes is defined and controlled.

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Is the default access specifier same as protected?

A private member of a class can only be accessed by methods of that class. A protected member of a class can only be accessed by methods of that class and by methods of a derived class of that class.


What is the application of public protected and private keywords?

The public, protected, and private keywords are access modifiers that specify if the item they modify can be accessed inside or outside the class or a derived class.A public item is fully accessible, inside or outside the class, including inside a derived class.A protected item is accessible only inside the class or inside a derived class.A private item is accessible only inside the class.


Can a derived class make a public base function private true or false?

True. A derived class can make a public base function private. The derived function is private, within the derived class, but public in other contexts.


How can you access private functions of a class from the Main function in Cpp?

Any member functions and data members declared as 'private' in a class, can only be accessed directly by functions within the class.They cannot be accessed directly by derived objects, nor from anywhere outside an object of the class, such as from the Main function.To access private class members, you must rely on what are called accessor functions. Accessor functions are functions inside the class, either public or protected, which automatically have access to private members.If a function from Main, or elsewhere outside the class hierarchy, needs access, then you need to use publicaccessor functions. For derived class access, you can use protected accessor functions.


Difference between private and protected specifier in c plus plus language?

In C++, the private specifier means that the item can only be accessed by methods of the class, not including methods of derived classes. Protected, on the other hand, means the item can be accessed by methods of the class, and methods of derived classes. Public, to complete the explanation, means that the item can be acessed by any method, this class, another class, or otherwise.

Related Questions

What is private specifier in c plus plus?

The private specifier states that the member can only be accessed by the containing class, and not by any derived class, nor by any other code outside of a class.


Is the default access specifier same as protected?

A private member of a class can only be accessed by methods of that class. A protected member of a class can only be accessed by methods of that class and by methods of a derived class of that class.


Is it publicly-held or private-held company?

Accuride Corporation is publicly-held or private-held company?


What is the application of public protected and private keywords?

The public, protected, and private keywords are access modifiers that specify if the item they modify can be accessed inside or outside the class or a derived class.A public item is fully accessible, inside or outside the class, including inside a derived class.A protected item is accessible only inside the class or inside a derived class.A private item is accessible only inside the class.


Private in java?

The private identifier is used to specify that an element can not be directly accessed from the outside. For example, a field or method declared as private can not be accessed directly from outside of the object or class in which it is used.


Can a derived class make a public base function private true or false?

True. A derived class can make a public base function private. The derived function is private, within the derived class, but public in other contexts.


What is a private brand?

It is a brand that is not publicly traded.


What is the major difference between public and private access method in computer programming?

public means this can be accessed from any class private means this can be accessed only from the current class


Is Forever 21 a publicly traded company?

No, Forever 21 is a private company. It is not publicly traded.


Is livescribe a publicly traded company?

No. It is a private company.


Is Toyota a private or a public company?

Toyota is a publicly traded company.


How can you access private functions of a class from the Main function in Cpp?

Any member functions and data members declared as 'private' in a class, can only be accessed directly by functions within the class.They cannot be accessed directly by derived objects, nor from anywhere outside an object of the class, such as from the Main function.To access private class members, you must rely on what are called accessor functions. Accessor functions are functions inside the class, either public or protected, which automatically have access to private members.If a function from Main, or elsewhere outside the class hierarchy, needs access, then you need to use publicaccessor functions. For derived class access, you can use protected accessor functions.