📊 C++
Q. What is the output of the following C++ code?
Code:
#include<iostream>

using namespace std;

class Point {
private:
    int x;
    int y;
public:
    Point(int a, int b);
};

Point::Point(int a = 0, int b = 0)  {
    x = a;
    y = b;
    cout << "Constructor called";
}
  
int main()
{
   Point p1, *p2;
   return 0;
}
  • (A) Displays “Constructor called” only once.
  • (B) Displays “Constructor called” twice.
  • (C) Does not display anything.
  • (D) Compilation error
💬 Discuss
✅ Correct Answer: (A) Displays “Constructor called” only once.

You must be Logged in to update hint/solution

💬 Discussion


📊 Question Analytics

👁️
198
Total Visits
📽️
4 y ago
Published
🎖️
Dharmendra Sir
Publisher
📈
98%
Success Rate