I tried to outsource some functions in another.cpp but if I change someObject
in another.cpp, it has to effect someObject
in main.cpp.
So this is basically the structure now. Which doesn't affect camera
.
main.cpp
someObject camera;
setCamera(someObject camera);
int main()
{
setCamera(camera);
camera.doSomething();
}
another.cpp
someObject tempCamera;
void setCamera(someObject camera)
{
tempCamera = camera;
}
void anotherFunction()
{
tempCamera.doSomethingElse();
}
so what I want to do is making tempCamera
pointing to camera
,
but when I do it like this:
someObject *tempCamera;
void setCamera(someObject camera)
{
tempCamera = &camera;
}
anotherFunction()
{
tempCamera.doSomethingElse();
}
I get an error, that the expression must have a class
type.
My Question now is: How do I call a function from a pointer or what alternatives do I have?