您的位置:首页 > 其它

静态成员的使用

2015-09-22 22:00 246 查看
<span style="font-size:18px;">#include<iostream>
using namespace std;
class book
{
private:
	static int couter;
public:
	book(char* title)
	{
		cout << "售出的书" << title << endl;
		couter++;
	}
	static int getcouter()
	{
		return couter;
	}
};
int book::couter = 0;
int main()
{
	typedef char strings[100];
	strings title[] = { "实验书", "编程数", "视频书" };
		for (int i = 0; i < 3; i++)
		{
			new book(title[i]);
		}
		cout << "总数" << book::getcouter << "图书" << endl;
		system("pause");
		return 0;
}</span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: