Putting my comment into an answer: references cannot be rebound, and it is bound in the constructor in your case. They have to be bound in the constructor initializer list, at least pre-c++11, and you are doing that over here:
Agg():m(MyPOD()){}
^^^^^^^^^^
What you seem to be working on later is a copy basically into that already bound variable which would also chang ethe original variable that it refers to, but in your case that is only MyPOD()
.
By the way, that is a temporary variable, so even if it seems to work OK currently, do not use it. There is no guarantee for it to remain working. It actually does not even compile with gcc 4.9 on my Archlinux giving this:
main.cpp: In constructor ‘Agg::Agg()’:
main.cpp:12:19: error: invalid initialization of non-const reference of type ‘MyPOD&’ from an rvalue of type ‘MyPOD’
Agg():m(MyPOD()){}
or clang version 3.4:
main.cpp:12:10: error: non-const lvalue reference to type 'MyPOD' cannot bind to a temporary of type 'MyPOD'
Agg():m(MyPOD()){}
^ ~~~~~~~
1 error generated.
Which means you cannot set a non-const reference from a temporary (rvalue).
So, in short, your comment is wrong here:
Agg a;
a.m=p; //referencing the object above
This would be the proper commenting:
Agg a;
a.m=p; //copying the object above by using the assignment operator