Classes within classes

I wanted to have an object of a custom class as a member of another class. I accessed the object by a getter and changed one of its members by a setter:

First.getSecond().setNumber(5);

The member gets changed inside of set number, however is not changed when checked later again.

What is wrong here?

Zip attached for the full example.

TwoClasses.zip (14.5 KB)

Please attach code to your post. Hosting it on an insecure site like dropbox means that it is not accessible to me at work.

I edited the original post and added the code. I did not see that there was an attach option.

You're passing around copies of the second class.

When you return a class you return a copy of the class.

You should either pass pointers around (Second *widget), or use the ByRef operator (Second widget&).

Oh hell. I am not new to C++ but I di not use it for a long time and forgot about the byref operator... Thanks for your answer!