Return by value in you function seems fine as the copy of the created object will be sent to the caller and nothing is problamatic. although if the size of the object is big then it might be a little performance overhead.
The second function declaration accepts a reference and you will assign that reference or change that reference values inside the function, which could work fine but this will make the caller resposible for creating the object and passing it by reference.
The convention is more like: pass all objects by const reference if you dont want them to get changed. pass them by pointer if you want them to get changed inside the function.
so I will say either you keep the original methid as is (little performance overhead on copy constructor call) or use pointer to do same thing.
function:
void GetClass(CString C, one * class_one)
{
class_one = new one();
if(C == "GO")
{
class_one->Add(5.4);
}
else
{
class_one->Add(3.5);
}
}
and call as:
One *one;
GetClass(C, one);
I might be wrong, someone can perhaps correct me of ratify this.