C++ | Constructors | Question 4

filter_none

edit
close

play_arrow

link
brightness_4
code

#include<iostream>
using namespace std;
class Point {
public:
    Point() { cout << "Constructor called"; }
};
  
int main()
{
   Point t1, *t2;
   return 0;
}

chevron_right


(A) Compiler Error
(B) Constructor called
Constructor called

(C) Constructor called


Answer: (C)

Explanation: Only one object t1 is constructed here. t2 is just a pointer variable, not an object

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.