#pragma once
//利用宏声明方法 利用该宏
#define DECLARE_TEST_METHOD(_T)\
_T Test ## _T(_T&);\
_T Test ## _T ## 1(_T&);
class Demo
{
public:
//声明int类型的方法
DECLARE_TEST_METHOD(int);
DECLARE_TEST_METHOD(double);
};
#include "Demo.h"
#include <iostream>
#include <string>
using namespace std;
//定义相应的方法
int Demo::Testint(int& num)
{
return num + 1;
}
double Demo::Testdouble(double& num) {
return num + 1.0;
}
double Demo::Testdouble1(double& num) {
return num + 2.0;
}
//在控制台使用
int main()
{
Demo demo;
int n = 20;
n = demo.Testint(n);
std::string str = "hahaha";
double d = 30.225;
d = demo.Testdouble(d);
d = demo.Testdouble1(d);
std::cout << str << std::endl;
}
标签:demo,int,Demo,C++,用法,---,##,num,double From: https://www.cnblogs.com/HRDK-CADeveloper/p/16924289.html