class A {
public:
void f();
protected:
A() {}
A(const A&){}
};
Examine the class declaration shown above. Why are the
default and copy constructors declared as protected?
1. To ensure that A cannot be created via new by a more
derived class
2. To ensure that A cannot be copied
3. To ensure that A cannot be used as a base class except
when public inheritance has been used
4. To ensure that A cannot be created/copied outside the
inheritance chain
5. To ensure that A cannot be instantiated as a static variable
Answer Posted / prasenjit roy
4. To ensure that A cannot be created/copied outside the
inheritance chain
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is pointer -to-members in C++? Give their syntax?
find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.
What is c++ & why it is used?
Is the declaration of a class its interface or its implementation?
What is the difference between a reference and a pointer?
What is null c++?
Can I learn c++ without c?
Can we define function inside main in c++?
Is c++ pass by reference or value?
How is c++ used in the real world?
State the difference between pre and post increment/decrement operations.
What are c++ tokens?
How c functions prevents rework and therefore saves the programers time as wel as length of the code ?
What is ifstream c++?
How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?