What is the output of the following C++ code? class Point { private: int x; int y: public: Point(int a = 0, int b=0); // Normal constructor Point(const Point &p); // Copy Constructor }; Point Point(int a, int b) { x = a; y = b; cout << "Normal constructor called A\n"; } Point Point(const Point &p) { X=RX y = Ry: cout << "Copy constructor called B\n"; } int main() { Point *p1, *p2; pl = new Point(5, 10); p2 = new Point(*p1); Point p3 = *p1; Point p4; p4=p3; return 0; } بتك

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.2: Providing Class Conversion Capabilities
Problem 6E
icon
Related questions
Question
What is the output of the following C++ code?
class Point {
private:
int x;
int y:
public:
Point(int a = 0, int b=0); // Normal constructor
Point(const Point &p); // Copy Constructor
};
Point Point(int a, int b) {
x = a;
y = b;
cout << "Normal constructor called A\n";
}
Point Point(const Point &p) {
X=RX
y = p.y:
cout << "Copy constructor called B\n";
}
int main()
{
Point *p1, *p2;
pl = new Point(5, 10);
p2 = new Point(*p1);
Point p3 = *p1;
Point p4;
p4=p3;
return 0;
}
إجابتك
Transcribed Image Text:What is the output of the following C++ code? class Point { private: int x; int y: public: Point(int a = 0, int b=0); // Normal constructor Point(const Point &p); // Copy Constructor }; Point Point(int a, int b) { x = a; y = b; cout << "Normal constructor called A\n"; } Point Point(const Point &p) { X=RX y = p.y: cout << "Copy constructor called B\n"; } int main() { Point *p1, *p2; pl = new Point(5, 10); p2 = new Point(*p1); Point p3 = *p1; Point p4; p4=p3; return 0; } إجابتك
Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr