1、若要查看销毁 Cardgame 对象时发生的情况,请查看 Cardgame 类的析构函数。
- 在菜单栏上,选择“视图” > “类视图”。
- 在“类视图”窗口中,展开“Game”项目树并选择“Cardgame”类来显示类成员和方法 。
- 打开“~Cardgame(void)”析构函数的快捷菜单,然后选择“转到定义” 。
2、修改Cardgame.cpp
#include "Cardgame.h"
#include <iostream>
using namespace std;
int Cardgame::totalParticipants = 0;
Cardgame::Cardgame(int players)
: players(players)
{
totalParticipants += players;
cout << players << " players have started a new game. There are now "
<< totalParticipants << " players in total." << endl;
}
Cardgame::~Cardgame()
{
totalParticipants -= players;
cout << players << " players have finished their game. There are now "
<< totalParticipants << " players in total." << endl;
}
3、在菜单栏上,依次选择“生成” > “生成解决方案” 。
4、生成完成后,可以通过选择菜单栏上的“调试” > “启动调试”或选择 F5 键在调试模式下运行此解决方案。 程序在第一个断点处暂停程序。