- 1

Can we access Private protected and public access specifiers at the same time in c++?

Hello every body. in c++ oop we create classes and in the class we use something called access specifiers my question is, is it possible to access all the access specifiers at the same time... while inherating the features of the base class(existing class) to the derived class(child class).... thank you all in advance

20th Apr 2018, 2:31 PM
kashif ahmad
kashif ahmad - avatar
4 odpowiedzi
+ 2
How do you mean "access access specifiers"? A friend function can access private and protected variables.
20th Apr 2018, 2:33 PM
Timon Paßlick
+ 2
In your sum class, you can't access private members of multiply but all the public things from multiply are private in sum. To access private variables, use the friend keyword.
20th Apr 2018, 2:48 PM
Timon Paßlick
+ 2
The meaning of the friend declaration is the same whether the friend declaration appears in the private, protected or public portion of the class member-specification. so yes using friend function u can access all members declared as private,protected and public.
21st Apr 2018, 1:25 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
0
bro we have 3 access specifiers in the class. private . public. protected. while a creating a new child class from base class we use a syntax. i.e parent class : access specifiers child class. suppose i have a class sum. and now i want to create a new class . sum : private multiply { }; this is the syntax i want or my mean is can i use smthing instead private to access all the access specifiers.. hope u got me....
20th Apr 2018, 2:43 PM
kashif ahmad
kashif ahmad - avatar