C++范例之-默认构造函数、拷贝构造函数、析构函数

C++实例之-默认构造函数、拷贝构造函数、析构函数
// Test1.cpp : Defines the entry point for the console application.
//

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

using namespace std; 

class Internet 
{ 
	public: 
		Internet() 
		{ 
			cout<<"载入默认构造函数"<<endl; 
		}; 
		Internet(char *name,char *address) 
		{ 
			cout<<"载入构造函数"<<endl; 
			strcpy(Internet::name,name); 
		} 
		Internet(Internet &temp) 
		{ 
			cout<<"载入COPY构造函数"<<endl; 
			strcpy(Internet::name,temp.name); 
			cin.get(); 
		} 
		~Internet() 
		{ 
			cout<<"载入析构函数!"; 
		} 
	protected: 
		char name[20]; 
		char address[20]; 
}; 

Internet tp() 
{ 
	Internet b("....","www.zzz.com"); 
	return b; 
} 

void main() 
{ 
	/*情形一
		//载入构造函数
		Internet b("....","www.zzz.com"); 
		//载入COPY构造函数
		Internet a(b); 
		//载入析构函数!载入析构函数!
	*/


	/*情形二
		//载入默认构造函数
		Internet a; 
		//载入构造函数
		Internet b("....","www.cndev-lab.com"); 
		a=b; 
		//载入析构函数!载入析构函数!
	*/

	/*情形三
		//载入默认构造函数
		Internet a; 
		//载入构造函数!
		//载入COPY构造函数
		a=tp(); 
		//载入析构函数!载入析构函数!载入析构函数!
	*/
}