X
xllx.relient.xllx
Assuming compiler optimizations are set to off, specifically to not
allow the compiler to elide the copy constructor, would the following
hold true?:
If you call a function with an user-defined object by value as it's
first and only argument, and this object was created before the
function call (named object), would the compiler call the copy
constructor to create a temporary object and initialize this object
with the formal argument (what's being passed) and then, another copy
constructor call would be made to initialize the actual argument object
in the function definition with the previous temporary object? In
essense, would two copy constructor calls be made in the situation
presented or would only one copy constructor be called and if so, why?
and.., is returning an object (by value also) any different from
passing?
code:
void theCall(Foo foo) {
// ...
}
int main(int, char**)
{
Foo foo;
theCall(foo);
}
allow the compiler to elide the copy constructor, would the following
hold true?:
If you call a function with an user-defined object by value as it's
first and only argument, and this object was created before the
function call (named object), would the compiler call the copy
constructor to create a temporary object and initialize this object
with the formal argument (what's being passed) and then, another copy
constructor call would be made to initialize the actual argument object
in the function definition with the previous temporary object? In
essense, would two copy constructor calls be made in the situation
presented or would only one copy constructor be called and if so, why?
and.., is returning an object (by value also) any different from
passing?
code:
void theCall(Foo foo) {
// ...
}
int main(int, char**)
{
Foo foo;
theCall(foo);
}