c ++ True and False Questions
Posted on 2011-03-17
I need to figure if these are true or false, any help would be greatly appreciated...
8. If B is a base class of D, then D’s members cannot access the private data members of B without regard to the kind of inheritance.
9. An overloaded operator= function must be a non-static class member.
10. One constructor of a class can call another constructor of the same class to initialize the this object
11. When overloading (), , -> or any assignment operator, the operator overloading function must be declared as a class member.
12. A copy constructor is used to initialize an object with another object of the same class. Copy constructors are also invoked whenever a copy of an object is needed, such as in call-by-value, and when returning a value from a called function. In a copy constructor, the object being copied must be passed in by reference.
13. To overload the increment operator to allow both pre-increment and post-increment usage, each overloaded operator function must have a distinct signature so the compiler will be able to determine which version of ++ is intended.
14. Derived classes can provide their own implementations of a base class virtual function if necessary, but if they do not, the base class's implementation is used.
15. With single inheritance, a class is derived from only one base class. With multiple inheritance, a derived class inherits from multiple (possibly unrelated) base classes.
16. A derived class cannot access the private members of its base class; allowing this would violate the encapsulation of the base class. A derived class can, however, access the public and protected members of its base class.
17. An object of a derived class can be treated as an object of its corresponding public base class. However, the reverse is not true.
18. When deriving a class from a private base class, public and protected members of the base class become private members of the derived class.
19. For a derived-class object, first the base-class constructor is called, then the derived-class constructor is called (which may call member object constructors).
20. An attempt by a const member function of a class to modify an object of that class is a syntax error.