testsingleton.cpp

来自「financal instrument pricing using c」· C++ 代码 · 共 30 行

CPP
30
字号
// testSingleton.cpp
//
// Testing the generic Singleton pattern.
//
// (C) Datasim Education BV 2004
//

#include "singleton.cpp"
#include <iostream>
using namespace std;

class AnyOldThing
{
private:
	int j;
public:
	AnyOldThing() { j = 0;}

	int coeff() const { return 0;}

};

int main()
{
	AnyOldThing* pp = Singleton<AnyOldThing>::instance();

	cout << pp -> coeff() << endl;

	return 0;
}

⌨️ 快捷键说明

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