⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 currencyoverload.cpp

📁 datastucutre and algorithms, application, in C
💻 CPP
字号:
// test currency class with operator overloading

#include <iostream>
#include "currencyOverload.h"

using namespace std;

int main()
{
   currency g, h(plus, 3, 50), i, j;

   // try out both forms of setValue
   g.setValue(minus, 2, 25);
   i.setValue(-6.45);

   // do an add and output
   j = h + g;
   cout << h << " + " << g << " = " << j << endl;

   // do an increment and output
   cout << i << " incremented by " << h
        << " is " << (i += h) << endl;

   // do two adds in a sequence
   j = i + g + h;
   cout << i << " + " << g << " + " 
        << h << " = " << j << endl;

   // do an increment and add
   cout << "Increment " << i << " by " << g
        << " and then add " << h << endl;
   j = (i += g) + h;
   cout << "Result is " << j << endl;
   cout << "Incremented object is " << i << endl;

   // test the exception
   cout << "Attempting to initialize with cents = 152" << endl;
   try {i.setValue(plus, 3, 152);}
   catch (illegalParameterValue e)
   {
      cout << "Caught thrown exception" << endl;
      e.outputMessage();
   }
   return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -