博文
简单的计算器代码(2006-12-23 21:48:00)
摘要:#include <iostream>
#include "SimpleCalculator.h"
using std::cout;using std::endl;
int main(){ double a = 10.0; double b = 20.0; /* Declare any other variables needed here */ /* Instantiate an object of type SimpleCalculator */SimpleCalculator sc;// cout << "The value of a is: " << a << "\n" << "The value of b is: " << b << "\n\n"; double addition=sc.add(a, b); /* Write a line that adds a & b through your SimpleCalculator object; assign the result to a variable named "addition" */ cout << "Adding a and b yields " << addition << "\n";
double subtraction=sc.subtract( a, b );
cout << "Subtracting b from a " << subtraction << "\n";
 ......
