Friday, July 31, 2009

Write in c++, using class to add two distences entered in feet & inches and store the result inthird distance?

pass two distances as argument to a function and the function should return the added distance.use required constructors %26amp; methods in your program.

Write in c++, using class to add two distences entered in feet %26amp; inches and store the result inthird distance?
Too easy.


Enjoy.





- Hex














#include %26lt;iostream%26gt;


#include %26lt;conio.h%26gt; //for getch();








using namespace std;








class MyClass


{


public:


int MyCalculator(int Dis1, int Dis2);


};





int MyClass::MyCalculator(int Dis1, int Dis2)


{


return Dis1 + Dis2;


}





int main()


{


MyClass MC;


cout %26lt;%26lt; MC.MyCalculator(203, 492);





cout %26lt;%26lt; "\nPress any key to close...\n";


getch();


}


No comments:

Post a Comment