Advertisement
TheWhiteFang

Tutorial 7 Q5

Jan 14th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. //pastebin.com/u/thewhitefang
  2. //tutorial 7 q5
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. class RM {
  9. int m_ringgit;
  10. double m_sen;
  11.  
  12. public:
  13. RM(){
  14. m_ringgit = 0;
  15. m_sen = 0;
  16. }
  17. RM(double inVal){
  18. m_ringgit = (int)inVal;
  19. m_sen = inVal - m_ringgit;
  20. }
  21.  
  22. friend ostream &operator<<(ostream &output, const RM &source);
  23. };
  24.  
  25. RM operator+ (const RM &inVal1, const RM &inVal2)
  26. {
  27. RM temp;
  28. };
  29.  
  30. ostream &operator<<(ostream &output, const RM &source){
  31. output << source.m_ringgit << "and " <<source.m_sen <<endl;
  32.  
  33. return output;
  34. }
  35.  
  36. int main(){
  37.  
  38. RM acct1;
  39. RM acct2;
  40. acct1 = 50.99;
  41. acct2 = 25.50;
  42. cout << "amount: " << acct1 << endl;
  43. cout << "acct1 + acc2: " << acct1 + acct2<< endl;
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement