How could I, in C++ declare a class point. The class point has two private data members x and y of type float. The class point has a parameterized constructor to initialize both the data members i.e. x and y. The class point has a member function display() that display the value of x and y. Create two objects p1 and p2 with your desired data and display the values of x and y of p1 and p2. Now create a third object p3 by using the expression p3=p1+p2 and display the values of x and y of p3.

Showing Answers 1 - 1 of 1 Answers

AvinashChaturvedi

  • Aug 3rd, 2006
 

HI,

     For Ur Problem U Must use opretor overloading . with the help of this concept u implement a member function into ur class ( point in ur case) for overload the default functionality of + operator.

Regards,

Avinash Chaturvedi ( Avi )

    

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions