If a base class member access is public, and an inherited class accesses specifier is private, which of the following statement is true ?
Overall Stats
Answers
D. A is wrong because the base class member can be assessed by the derived class not its objects. This is the same for B. And base class objects can never access derived class members.
-
Log in to add a comment
Baby Devi is saying The derived class members can be accessed by the base class objects is correct answer
saksham srivastava is saying The derived class members can be accessed by the base class objects is correct answer
vasundhara gour is saying The base class member can be accessed by derived class objects is correct answer
Kabir Sharma is saying None of above is correct answer
Related Questions
what is Hybrid Inheritance?
- [A] multiple inheritance
- [B] multilevel inheritance
- [C] multipath inheritance
- [D] combination of a and b
- [E] combination of a and c
Choose most appropriate statement
- [A] An abstract base class can have pure virtual destructor
- [B] An abstract base class can have only virtual destructor
- [C] An abstract base class can have non virtual destructor
- [D] An abstract base class cannot have destructor
Which of the following is false with respect to inheritance?
- [A] When a base class is privately inherited,public members of the base class become private members of the derived class
- [B] When a base class is publicly inherited,public members of the base class becomes public members of derived class
- [C] When a base class is privately inherited,a private member of base class becomes private member of derived class
- [D] When a base class is publicly inherited protected members of base class becomes protected members of derived class
what will the ouput of the following code be?
#include
using namespace std;
class parent
{
public:
int x, y;
parent(int a, int b) { x = a; y = b; }
parent() { x = y = 0; }
void print() { cout << x << " " << y << " "; }
};
class child : public parent
{
public:
int a, b;
child(int a, int b) { this->a = a; this->b = b; }
void print() { cout << x << " " << y << " " << a << " " << b << " "; }
};
int main()
{
parent p(3,4);
child c(1,2);
p = (parent)c;
c.print();
p.print();
return 0;
}
- [A] 0 0 1 2 0 0
- [B] 0 0 1 2 3 4
- [C] 3 4 1 2 3 4
- [D] Compiler error
The conversion from basic data to class type can be done by .......
- [A] Writing constructor
- [B] Is not possible
- [C] overloaded casting operator
- [D] object of a class