In my program i am passing a locally constructed variable to a global class object’s member function. The member function will assign this variable to a private member and use it through out the program. Is there any drawback in this approach?
public void function()
{
int a = 0;
globalClassObject.StoreValue(a);
}
This is fine. The problem would be if you would pass a reference to this variable. In this case the value is “copied” to the variable within the function so the original
avariable isn’t actually used.