ston.cpp

来自「我学习C++ Primer Plus过程中写下的课后作业的编程代码」· C++ 代码 · 共 58 行

CPP
58
字号
// stone.cpp -- user-defined conversions
// compile with stonewt.cpp
#include <iostream>
using std::cout;
using std::endl;
#include "stonewt.h"

int main()
{
	Stonewt pavarotti = 260;		// uses constructor to initialize
	Stonewt wolfe (285.7);			// same as Stonewt wolfe = 285.7
	Stonewt taft (21, 21);			// NOTE: 21 stones and 21 pounds
	Stonewt wolfe_and_taft;

	cout<<"The tenor weighed "
		  "pounds mode: ";			// pounds mode
	cout<<pavarotti;
	cout<<"The tenor weighed "		// stone mode
		  "stone mode: ";
	pavarotti.stn_mode();
	cout<<pavarotti<<endl;

	cout<<"The detective weighde "
		  "stone mode: ";			
	wolfe.stn_mode();				// change to stone mode
	cout<<wolfe;
	cout<<"The detective weighde "	// change to pounds mode
		  "stone mode: ";
	wolfe.pds_mode();
	cout<<wolfe<<endl;

	cout<<"The President weighde ";
	cout<<taft;
	taft.stn_mode();
	cout<<"The President weighde ";
	cout<<taft<<endl;


	wolfe_and_taft = wolfe + taft;	// +
	cout<<"wolfe 和 taft的体重一共为: ";
	cout<<wolfe_and_taft;
	wolfe_and_taft.stn_mode();
	cout<<"wolfe 和 taft的体重一共为: ";
	cout<<wolfe_and_taft<<endl;

	wolfe_and_taft = taft - wolfe;	// -
	cout<<"taft 比 wolfe的体重重: ";
	cout<<wolfe_and_taft;
	wolfe_and_taft.stn_mode();
	cout<<"taft 比 wolfe的体重重: ";
	cout<<wolfe_and_taft<<endl;

	wolfe_and_taft = wolfe * taft;
	cout<<"wolfe的体重 乘以 taft的体重为: ";
	cout<<wolfe_and_taft<<endl;
	return 0;
}

⌨️ 快捷键说明

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