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?

use the sequencing (comma) operator

im stumped brah do you have a soultion?

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

if order of calling does not matter, also

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

Vijay: The second suggestion won't work because the function return values are not consistent with parameter expectations.

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]

You're right, I was just checking to see if you were paying as much attention as I was :) :)

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.

lol

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;
}

my professor still says its not vaild lol

is it because im missing a function type?

what did you show him?

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;}

tell me about it this guy is so anal....no homo

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:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.