Reference "NewObject" outside of constructor

So I’m a little boggled as to how to edit a dynamically created Object outside of it’s constructor, for instance…

MakeObject
{
ObjectName->NewObject()
}

How do I then reference that same object in another function.

MoveForward
{
//Move already spawned object
ObjectName->ObjectPosition
}

(I know the code is very messy, its for example not live use)




private ObjectType myObject;

void MyClassName::MakeObject()
{
    myObject  = ObjectName->NewObject();
}

MoveForward
{
  //Move already spawned object
  if(myObject)
  { 
     myObject->ObjectPosition
  }
}




You need save the value that NewObject returns somewhere.