第二十一章,析构函数初探(C++)

时间:2015-06-15 18:52:33   收藏:0   阅读:103

NPC.h

#ifndef NPC_H
#define NPC_H
#include <string>

class NPC
{
	public:
		//构造函数 
		NPC();
		//析构函数 
		~NPC();
		
	protected:
};

#endif
NPC.cpp

#include "npc.h"
#include <iostream>

//构造函数 
NPC::NPC(){
	std::cout<<"初始化。。。"<<std::endl; 
}
//析构函数 
NPC::~NPC(){
	std::cout<<"结束。。。"<<std::endl; 
}
main.cpp

#include <iostream>
#include "NPC.h"

int main(int argc, char** argv) {
	NPC npc;
	return 0;
}
调试截图:

技术分享

原文:http://blog.csdn.net/qingbowen/article/details/46504923

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!