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

📄 world.cpp

📁 《c++ 实践之路》光盘中的源代码
💻 CPP
字号:
// (c) Bartosz Milewski, 2000

#include <iostream>

class Matter
{
public:
	Matter (int id)
		: _identifier (id)
	{
		std::cout << "  Matter for " << _identifier 
			<< " created\n";
	}
	~Matter ()
	{
		std::cout << "Matter in " << _identifier 
			<< " annihilated\n";
	}
private:
	const int _identifier;
};

class World
{
public:
	World (int id)
		: _identifier (id), 
		  _matter (_identifier) // initializing embeddings
	{
		std::cout << "Hello from world " << _identifier << ".\n";
	}

	~World ()
	{
		std::cout << "Goodbye from world " << _identifier << ".\n";
	}
private:
	const int      _identifier;
	const Matter   _matter; // Embedded object of type Matter
};

World TheUniverse (1);

int main ()
{
	World smallWorld (2);
}

⌨️ 快捷键说明

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