CS 162 Lecture Notes - Lecture 16: Move
CS 162 – Lecture 16 – Friends and Operator Overload
Using Inherited Objects in Function
o Void tes_bishop(Bishop& p, int r, int c){
▪ Bool res = p.check_valid(r, c);
▪ If (res)
• P.move(r,c);
▪ Else
• Cout << MOVE I“ NOT VALID << edl;
o }
o void test_piece(Piece& p, int r, int c){
▪ bool res = p.check_valid(r,c);
▪ if (res)
• p.move(r,c);
▪ else
• out << MOVE I“ NOT VALID << edl;
o }
o Bishop b;
o Test_bishop(b,3,0); // two functions will not have same result
o Test_piece(b,3,0);
o You can make a function that is the same but will work with different children
(cover this on Friday)
▪ Do’t use o assiget 3
▪ Write different arrays for houses, apartments, business complexes
• Not one for all properties
o “iilarities etee lasses, ake a paret lass so that you do’t hae to rite
the same code over and over again
Operator Overload
o Able to overload the assignment operator, why not others?
find more resources at oneclass.com
find more resources at oneclass.com