1. 程式人生 > >靜態函數調用非靜態函數的小樣例

靜態函數調用非靜態函數的小樣例

mark font main data text center char* printf ret

// tt.cpp : 定義控制臺應用程序的入口點。
//

#include "stdafx.h"

class A
{
public:
	void fun()
	{
		printf("1111111111");
	}

	static void fun2()
	{
		fun();
	}
};

int _tmain(int argc, _TCHAR* argv[])
{
	A a;
	A::fun2();

	return 0;
}

技術分享


// tt.cpp : 定義控制臺應用程序的入口點。
//

#include "stdafx.h"

class A
{
public:
	void fun()
	{
		printf("1111111111");
	}

	static void fun2(A a)
	{
		a.fun();
	}
};

int _tmain(int argc, _TCHAR* argv[])
{
	A a;
	A::fun2(a);

	return 0;
}



靜態函數調用非靜態函數的小樣例