Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

WHY

Name: Anonymous 2010-11-26 10:01

Why c++ passes arguments to functions in reverse? Like here:
[code=c++]
#include <iostream>

class yoba
{public:
yoba(int i, int o, int r){}};


void lalala(int i, int o, int r){}


int getOne(){std::cout << "One" << std::endl; return 1;}
int getTwo(){std::cout << "Two" << std::endl; return 2;}
int getThree(){std::cout << "Three" << std::endl; return 3;}


int main()
{
lalala(getOne(), getTwo(), getThree());
yoba* yobana = new yoba(getOne(), getTwo(), getThree());
return 0;
}
[/code]
Output:
[code=c++]
Three
Two
One
One
Two
Three
[/code]
And why "new" passes arguments correct?

Name: Anonymous 2010-11-26 10:04

Fuck off.
yoba
Back to whatever Russian imageboard you came from.

Name: Anonymous 2010-11-26 10:04

Nothing in any C++ (or C) standard requires the order of evaluation of arguments to be left-to-right.

Name: Anonymous 2010-11-26 10:09

>>2
>implying russian is something bad.
>>3
And what requires evaluation from right-to-left?

Name: Anonymous 2010-11-26 10:11

>>4
And what requires evaluation from right-to-left?
Read >>3 again, OP

Name: Anonymous 2010-11-26 10:15

>>5
He said that NOTHING requires evaluation from left-to-right, not that SOMETHING requires evaluation from right-ro-left.

Name: Anonymous 2010-11-26 10:16

>using C++
and now you have 2 problems

Name: Anonymous 2010-11-26 10:20

The order of evaluation of the arguments in a function call is unspecified. It just so happens that your compiler did it that way. The reason why is outside the scope of C and C++.

Name: Anonymous 2010-11-26 14:24

[code=c++]
yoba

gb2/c/

Don't change these.
Name: Email:
Entire Thread Thread List