CY PeriTech 0.0.x
载入中...
搜索中...
未找到
calculator.cpp
浏览该文件的文档.
1
5
6#include "calculator.h"
7
12Calculator::Calculator(double initialValue)
13 : value_(initialValue) {
14}
15
22 value_ += value;
23 return *this;
24}
25
33 if (divisor == 0.0) {
34 throw std::invalid_argument("除数不能为零");
35 }
36 value_ /= divisor;
37 return *this;
38}
39
44double Calculator::getValue() const noexcept {
45 return value_;
46}
计算器类的头文件
Calculator & add(double value)
加法运算
double getValue() const noexcept
获取当前值
Calculator(double initialValue=0.0)
构造函数
Calculator & divide(double divisor)
除法运算