C++ 宏使用进阶

#include "iostream"
#include "string.h"

using namespace std;

template
class Test {
public:
	void PrintHello() {
		cout << "Hello" << endl;
	}
};

#define GetPersonClassName(name)\
	public: \
		void Get##name##Name() {\
			cout << "gwx" << endl;\
		}\
		Test GetTest() {\
			return test##name;\
		}\
	private:\
		Test test##name;\

struct GWX {
	string name;
};

class PersonClass {
	GetPersonClassName(GWX);
};

int main() {
	PersonClass gwx;
	gwx.GetTest().PrintHello();

	return 0;
}

C++ 宏使用进阶_第1张图片

你可能感兴趣的:(c++,算法,开发语言)