339 views
0 votes
0 votes
if a class will serve as a base class , more often the base class data members are:-

a) private

b) public

c) protected

d) polymorphic

1 Answer

0 votes
0 votes

A base class is accessed by a derived class in one of the following ways:

1. Class X: public B

2. Class X: Private B

3. Class X: protected B

Member of a base class are always private by default. However they can made public  by using access specifier public.

If the base class is derived as public,then its data members can be accessed  directly by derived class members.

With private inheritance the public and protected members of base class becomes private members of derived class. They cannot be accessed directly by an object of derived class. 

With protected inheritance, The data members can be accessed by member functions of derived class and its friend function.

There is no term like most often, the members are private by default. And it is programmer's choice how she/he want to access them in the derived class.

Reference: 1. Page 346-351 , Book : Programming with C++, B.L. Juneja andAmita Seth.  (new Age International Publisher)

2. Page 405, Book: The C++ programming Language, Third Edition, Bjarne Stroustrup. 

3. https://en.wikipedia.org/wiki/C%2B%2B_classes

Related questions

0 votes
0 votes
0 answers
1
na2re2nder2 s2ingh asked Apr 6, 2017
315 views
which one of the following is not a client server application?a) internet chatb) web browserc) e-maild) pingplz provide reference also , if possible
0 votes
0 votes
1 answer
2
na2re2nder2 s2ingh asked Apr 5, 2017
576 views
A set of techniques that allow to execute a program which is not entirely in memory is?a-demand pagingb-virtual memoryc-auxilary memoryd-secondary memory
0 votes
0 votes
1 answer
3
na2re2nder2 s2ingh asked Apr 5, 2017
424 views
2's compliment of 0.01011?