gpt4 book ai didi

c++ - 如何在 C++ 中设置带参数的功能宏?

转载 作者:行者123 更新时间:2023-11-30 02:59:17 25 4
gpt4 key购买 nike

有什么方法可以让我完成这项工作吗?还是我需要使用单独的文件?

#include <iostream>                                                     // Necessary 
using namespace std;
#define long double mMaxOf2(long double min, long double max)
#define long double mMaxOf3(long double Min, long double Max, long double Mid)\
{\
mMaxOf2(mMaxOf2((Min), (Mid), (Max)));\
}

int main()
{
double primary;
double secondary;
double tertiary;
cout << "Please enter three numbers: ";
cin >> primary >> secondary >> tertiary;
cout << "The maximum of " << primary << " " << secondary << " " << tertiary;
cout << " using mMaxOf3 is " << (mMaxOf3(primary, secondary, tertiary));


return 0;
}

问题在于 mMaxOf3,它没有声明...嗯,也许我需要原型(prototype)。

最佳答案

多行宏需要在每行的末尾有一个\字符(最后一行除外)。

关于c++ - 如何在 C++ 中设置带参数的功能宏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13005119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com