Back To C++ Classes
//program to demonstrate example of function returning object of a class (class distance is created with data members feet and inches) and function add adds two distance objects and returns the resultant object #include
#include
class distance { int feet; int inches; public: int getfeet() { return feet; } int getinches() { return inches; } void setfeet(int f) { feet=f; } void setinches(int i) { inches=i; } void getdata() { cout<<"\nenter feet "; cin>>feet; cout<<"\nenter inches "; cin>>inches; } void showdata() { cout<<"\nfeet are "<