B
baibaichen
hi All
the following comes from c++ standards:
"Accessing an object designated by a volatile lvalue (3.10), modifying
an object, calling a library I/O
function, or calling a function that does any of those operations are
all side effects, which are changes in the
state of the execution environment."
According to this definition, consider this function,
T ReturnT(){
T result_;
//do something
return result_; // #1
}
At #1, I think
1) if T is scalre type such as int or char, the returning sentence
would not have side effects
2) if T is a class type, does returning type T have side effects? and
Why? I.e. which program state is changed in the T's copy constrcutor.
Thanks
Chang
the following comes from c++ standards:
"Accessing an object designated by a volatile lvalue (3.10), modifying
an object, calling a library I/O
function, or calling a function that does any of those operations are
all side effects, which are changes in the
state of the execution environment."
According to this definition, consider this function,
T ReturnT(){
T result_;
//do something
return result_; // #1
}
At #1, I think
1) if T is scalre type such as int or char, the returning sentence
would not have side effects
2) if T is a class type, does returning type T have side effects? and
Why? I.e. which program state is changed in the T's copy constrcutor.
Thanks
Chang