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



class A { public: void f(); protected: A() {} A(const A&){} }; Examine the ..

Answer / 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

More C++ General Interview Questions

Which software is best for c++ programming?

0 Answers  


What is the difference between = and == in C?

16 Answers   Christ University, Intel,


Find out the bug in this code,because of that this code will not compile....... #include <iostream> #include <new> #include <cstring> using namespace std; class balance { double cur_bal; char name[80]; public: balance(double n, char *s) { cur_bal = n; strcpy(name, s); } ~balance() { cout << "Destructing "; cout << name << "\n"; } void set(double n, char *s) { cur_bal = n; strcpy(name, s); } void get_bal(double &n, char *s) { n = cur_bal; strcpy(s, name); } }; int main() { balance *p; char s[80]; double n; int i; try { p = new balance [3]; // allocate entire array } catch (bad_alloc xa) { cout << "Allocation Failure\n"; return 1; }

2 Answers   Impetus,


What is a tree in c++?

0 Answers  


Why is standard template library used?

0 Answers  






What is code reusability in c++?

0 Answers  


What is a storage class?

0 Answers  


Is c better than c++?

0 Answers  


What are keywords in c++?

0 Answers  


In which situation the program terminates before reaching the breakpoint set by the user at the beginning of the mainq method?

0 Answers  


advantages and disadvantages of using Borland C++ / version 5.

1 Answers  


What is ios :: in in c++?

0 Answers  


Categories