How to set up a functional macro with parameters in C++?
- by user1728737
is there a way that I can make this work? Or do I need to use separate files?
#include <iostream> // Necessary
using namespace std;
long double primary, secondary, tertiary;
#define long double mMaxOf2(long double min, long double max)
{
return ((max > min) ? (max) : (min));
}
#define long double mMaxOf3(long double Min, long double Max, long double Mid)
{
long double Mid = (long double mMaxOf2(long double Min, long double Mid));
long double Max = (long double mMaxOf2(long double Mid, long double Max));
return (Max);
}
int main()
{
cout << "Please enter three numbers: ";
cin << primary << secondary << tertiary;
cout << "The maximum of " << primary << " " << secondary << " " << tertiary;
cout << " using mMaxOf3 is " << long double mMaxOf3(primary, secondary, tertiary);
return 0;
}
This is the error that I am getting.
|20|error: expected unqualified-id before '{' token|