• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C++ Constructors

Question 21

Output of following program? CPP
#include<iostream>
using namespace std;

class Point {
public:
    Point() { cout << \"Normal Constructor called\\n\"; }
    Point(const Point &t) { cout << \"Copy constructor called\\n\"; }
};

int main()
{
   Point *t1, *t2;
   t1 = new Point();
   t2 = new Point(*t1);
   Point t3 = *t1;
   Point t4;
   t4 = t3;
   return 0;
}
  • Normal Constructor called
    Normal Constructor called

    Normal Constructor called

    Copy Constructor called

    Copy Constructor called

    Normal Constructor called

    Copy Constructor called
  • Normal Constructor called
    Copy Constructor called

    Copy Constructor called

    Normal Constructor called

    Copy Constructor called
  • Normal Constructor called
    Copy Constructor called

    Copy Constructor called

    Normal Constructor called

Question 22

We must use initializer list in a constructor when
  • There is a reference variable in class
  • There is a constant variable in class
  • There is an object of another class. And the other class doesn\'t have default constructor.
  • All of the above

Question 23

Implicit return type of a class constructor is:
  • not of class type itself
  • class type itself
  • a destructor of class type
  • a destructor not of class type

Question 24

testing

  • test

Question 25

Test

  • Test

  • Test

Question 26

Test

  • Test

  • Test

There are 26 questions to complete.

Last Updated :
Take a part in the ongoing discussion