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?
[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?