庄生晓梦

庄生晓梦迷蝴蝶

博客园 首页 新随笔 联系 订阅 管理
// object_static_002.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;

class C1 {

public:
	C1() { cout << "c1构造" << endl; }
	C1( char* name ) { cout << name << "构造" << endl;}
	~C1() { cout << "C1析构" << endl;}

	void  fuck() { cout << "Test" << endl; }
};

class C2 {
	C1 member;
	static C1 static_member;
public:
	C2() { cout << "C2构造" ;  member.fuck(); }
	~C2() { cout << "C2析构" << endl;}

};


//C1 C2::static_member = C1( "static_member" );
C1 C2::static_member( "static_member" );

void test()
{
	C2 c;

}

int main(int argc, char* argv[])
{
	test();
	return 0;
}



执行结果

	
/*********************************
static_member构造
c1构造
C2构造Test
C2析构 C1析构 *********************************/


             

posted on 2012-06-03 16:07  qwop  阅读(174)  评论(0编辑  收藏  举报