Bootstrap

C++调用类成员函数

#ifndef _CLASS_H_
#define _CLASS_H_

class CanExtTxPDO_t
{
private:
	unsigned char i;
public:
    
	unsigned char buffer[10];

	CanExtTxPDO_t(unsigned char arg0, unsigned char arg1);
	~CanExtTxPDO_t(void);

	static void ClassFunc0(unsigned char arg0, unsigned char arg1);
	static void ClassFunc1(unsigned char arg0, unsigned char arg1);
	static void ClassFunc2(unsigned char arg0, unsigned char arg1);
};

#endif

// Class.cpp : 定义控制台应用程序的入口点。
//

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

CanExtTxPDO_t::CanExtTxPDO_t(unsigned char arg0, unsigned char arg1)
{	

}

CanExtTxPDO_t::~CanExtTxPDO_t(void)
{

}

void CanExtTxPDO_t::ClassFunc0(unsigned char arg0, unsigned char arg1)
{	
	using namespace std;
	cout <<"This is Class Function 0!" << endl;
}

void CanExtTxPDO_t::ClassFunc1(unsigned char arg0, unsigned char arg1)
{	
	using namespace std;
	cout <<"This is Class Function 1!" << endl;
}

void CanExtTxPDO_t::ClassFunc2(unsigned char arg0, unsigned char arg1)
{
	using namespace std;
	cout <<"This is Class Function 2!" << endl;
}

int main(int argc, _TCHAR* argv[])
{
	using namespace std;
	char ch;
	
	CanExtTxPDO_t::ClassFunc0(0, 0);
	CanExtTxPDO_t::ClassFunc1(0, 0);
	CanExtTxPDO_t::ClassFunc2(0, 0);

	cout <<"hello world!" << endl;

	system("pause");
	return 0;
}


输出结果:
This is Class Function 0!
This is Class Function 1!
This is Class Function 2!
hello world!

;