Consider the following function prototypes and variable declarations:

void Func1 (double, char &);
bool Func2 (double, double);
double Func3 (bool);

double d1, d2; char c;

Without additional function or variable, how do I write ONE C++ statement to call ALL THREE functions: Func1, Func2, and Func3?

Func1(d1,c), Func2(d1,d2), Func3(d1==d2) ;

if order of calling does not matter, also

Func1( Func3( Func2(d1,d2) ), c ) ;

could you tell me why? (i know i'm missing something obvious, but can't see what)
[edit]
got impatient ant tried it on a compiler. seems to work alright.
[/edit]

got impatient ant tried it on a compiler. seems to work alright.

Gee, maybe you should try that first next time... :icon_rolleyes:

Func1(d1,c), Func2(d1,d2), Func3(d1==d2) ;

if order of calling does not matter, also

Func1( Func3( Func2(d1,d2) ), c ) ;

Its not a valid C++ statement

what's not a valid c++ statement ? Both of them are valid. If you're talking about the second one, functions are frequently nested something like that. The output pf Func2 is passed as the first parameter to Func3, and the output of Func3 is passed as the first parameter to Func1.

hmmm...are you sure AD? How will this look if i where to compile this , because my professor disagrees

Either your professor is an idot or you misposted in your original post. See vijay's post #6 above, he already tried it and it works ok. And you can verify it yourself too my writing a small program to test that statement out.

my professor still says its not vaild lol

is it because im missing a function type?

How will this look if i where to compile this

I'm going to just quickly type this without attempt to compile it

void Func1 (double a, char & c) 
{
}

bool Func2 (double a, double b)
{
    return false;
}

double Func3 (bool a)
{
   return 0.0;
}

int main()
{
    double d1 = 0, d2 = 0;
    char c = 0;
    Func1( Func3( Func2(d1,d2) ), c ) ;
    return 0;
}

what did you show him?

i showed my professor Func1( Func3( Func2(d1,d2) ), c ) ;

because my professor stated

Without additional function or variable, write ONE C++ statement to call ALL THREE functions: Func1, Func2, and Func3.

so I figured that was accurate but my professors is still saying its invaild

Well, he is an idot. So I don't know what to tell you, unless he is wanting something stupid like this:

int main() { Func1( Func3( Func2(d1,d2) ), c ) {} return 0;}

Gee, maybe you should try that first next time... :icon_rolleyes:

Gee, maybe i should look up ISO/IEC 14882 first before i write main the next time... :icon_rolleyes:

This article has been dead for over six months. Start a new discussion instead.