How to set up a functional macro with parameters in C++?

Posted by user1728737 on Stack Overflow See other posts from Stack Overflow or by user1728737
Published on 2012-10-22T04:55:00Z Indexed on 2012/10/22 5:00 UTC
Read the original article Hit count: 148

Filed under:
|

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|

© Stack Overflow or respective owner

Related posts about c++

Related posts about homework