It will return a copy of your object. However, be careful if you modify the function declaration to return a link, your code will result in Undefined Behavior.
Example:
class CObject{
public:
CObject(){std::cout << "cosntructing ";}
CObject(const CObject& other){std::cout << "copying ";}
};
CObject getObject(){
CObject localObject;
CObject &objectRef(localObject);
return objectRef;
}
int main(){
auto result = getObject();
}
This will lead to:
cosntructing copy
: , - RVO. .
@Caduchon , - -.
undefined :
CObject& getObject() {
CObject localObject;
CObject &objectRef(localObject);
return objectRef;
}