請問c++的例外處理
#include <iostream>
#include <stdlib.h>
using namespace std;
class fraction{
private:
int numerator;
int denominator;
public:
void set_value()
{cout << "輸入分子:";
cin >> numerator;
cout << "輸入分母:";
cin >> denominator; }
void print_value()
{
//new
try {
cout << numerator << "/" << denominator << "=";
cout << (numerator/denominator) << endl; ;
}
catch (std::exception& e) {
cout << "例外發生: " << e.what() << endl;
}}
};
int main()
{ fraction X;
X.set_value();
X.print_value();
system("pause");
return 0;}
--
┌─────◆KKCITY◆─────┐ ◢ ◤ 找歌最方便 KKBOX 歌詞搜尋!!
│ bbs.kkcity.com.tw │ \^_^ / ★http://www.kkbox.com.tw★
└──《From:140.109.139.90 》──┘ ◤ 唱片公司授權,音樂盡情下載
--
→
07/07 20:09, , 1F
07/07 20:09, 1F
Programming 近期熱門文章
PTT數位生活區 即時熱門文章