you mean as a meber function of Container?
I will have this problem: error: member `void Container::operator+=(const Box&)' declared as friend before type `Container' defined|
It can be a friend function, it just needs to be declared in Container, not in Box, since Container is derived from Box (which also seems weird; a Box IS a Container, but not all Containers are Boxes.)