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

📄 304.cpp

📁 C++实训教程
💻 CPP
字号:
//304.CPP  creating & using objects
class Count
{
  private:	double 	total;
  public:
	void	initCount(void)	{total = 0.0;}
	void 	addTo(double d)	{total += d ;}
	double  getCount(void)	{return total;}
};
#include <iostream.h>
main()
{
	Count c1,c2;//declare Count object
	c1.initCount();		//init total
	c2.initCount();		//init total
	c1.addTo(10.0);
	c2.addTo(20.0);
	c1.addTo(100.0);
	c2.addTo(200.0);
	cout << "The Total c1 is:" << c1.getCount() << endl;
	cout << "The Total c2 is:" << c2.getCount() << endl;
	return 0;
}
/*
The Total c1 is:110
The Total c2 is:220
*/

⌨️ 快捷键说明

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