Question: (1)Develop a class Age which stores age of an individual in years and months. Using friend function, overload the + operator to add an integer
(1)Develop a class Age which stores age of an individual in years and months. Using friend function, overload the + operator to add an integer to an object of class Age. The integer should be added to the month field of age. Your program should allow statements like the following. Age a(20,5) ; //20 years , 5 months Age b ; b = a+5 ;//20 years, 10 months
(2)Create a class MyClass with an integer data member secret. Provide a constructor and display method in the class. Create another class, MyFriendClass and make it a friend of the class MyClass. Provide a function change() in the class MyFriendClass which accepts an object of class MyClass (by reference) and an integer. The change() function should assign the integer passed as an argument to the data member secret of the object received as input. Sample Run : MyClass m(2) ; MyFriendClass mf ; mf.change(m,10) ; m.display() ; //Should print 10
(3)Create a class 3D point to model points in 3-dimensional space. Provide appropriate constructors and get/set methods in the class. Using friend functions, overload the following operators. + operator to add two 3D points. - operator to subtract two 3D points. ~ operator to find the distance between two points.
All tasks in oop c++
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
