I've created already one topic (2months ago~)
You'll find my problem description in this link:
http://www.cplusplus.com/forum/general/131696/
I've tried now the following code:
void MyClass::setObject(int &i)
{
this->i = i;
}
using setter with reference has no real impact on performance, when using simple types/parameter (in this case int)
but when I use a vector with 10++ items, as parameter using reference for setter is twice as fast as without reference/pointer (tested it)
Using getter with reference:
int& MyClass::getObject()
{
return i;
}
or better:
const int& MyClass::getObject()
{
return i;
}
also has no impact using simple types,
much better performance when i use it for vectors or other "big things".
is even a better and faster way?
let me know your thoughts about this.
~slei