I would like to implement the + sign to add the my_Contents (int) of two class Mailbox's 'left' and 'right'.
ex.
Mailbox(test);
Mailbox(left);
Mailbox(right);
left.setSize( 10 ); //my_contents=10
right.setSize( 10 );//"" "" = 5
test.setSize( 5 );// "" ""=5
test = left + right;
However, class Mailbox is NOT initialized as Mailbox 'Name' (my_contents). Therefore my code below will not run. So how would I implement the operator '+' to apply to contents inside the class, which aren't used for initialization, as I am used to?
Mailbox operator +(const Mailbox& left,
const Mailbox& right) {
Mailbox t =Mailbox( left.my_Contents + right.my_Contents );
return( t );
}