Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Constructors and Destructors Questions
C++ object copying: which special member is used to make a copy of one object from another object of the same class type?
C++ default constructor definition: what do we call a constructor that has no parameters, or whose parameters all have default values?
C++ constructors: which statement about return types and contents of constructors is correct?
C++ constructors: which statement best describes overloading of constructors?
C++ default constructors: how many default constructors can a single class have?
In C++, when you allocate an array of objects using new[], how should you free that memory so that every element's destructor runs? Choose the correct form of the delete operator for arrays.
In C++ object lifetime management, which special member function is automatically executed when an object goes out of scope or is deleted?
In standard C++, which of the following entities cannot be declared as virtual? Select the most accurate combination.
Which of the following is NOT automatically provided by a C++ compiler when you do not define any of them yourself?
In C++, a class's destructor has the same base name as the constructor but is prefixed by which symbol? Select the correct leading character used in the destructor's syntax.
If a C++ programmer does not explicitly define a destructor for a class, who provides an empty destructor automatically?
In C++, when are global (namespace-scope, static-duration) objects destroyed?
Which statement correctly describes constructor and destructor naming rules in C++?
When you do not explicitly declare any constructors for a C++ class, which translation stage will implicitly declare a default (zero-argument) constructor if eligible?
Which of the following in C++ never requires any arguments by definition? Choose the construct that can always be invoked with zero parameters.
C++ object lifetime: how many times is a constructor invoked during the entire lifetime of a single object? Choose the most accurate statement.
C++ object scope: when an object goes out of scope, which special member function is invoked automatically?
C++ object creation: which special member function is invoked when an object is being created?
C++ constructors: which constructor is specifically designed to copy one object from another object of the same class type?
C++ base-class constructor vs member-object constructor: trace printed members. #include
class CuriousTabBase { public: int x, y; CuriousTabBase(int xx = 0, int yy = 0) { x = xx; y = yy; } }; class CuriousTabDerived : public CuriousTabBase { private: CuriousTabBase objBase; public: CuriousTabDerived(int xx, int yy) : CuriousTabBase(xx), objBase(yy) { cout << this->x << " " << this->y << " " << objBase.x << " " << objBase.y << " "; } ~CuriousTabDerived() {} }; int main() { CuriousTabDerived objDev(11, 22); return 0; }
1
2
3