CS 162 Lecture Notes - Lecture 16: Move

51 views4 pages
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 << edl;
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 << edl;
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 assiget 3
Write different arrays for houses, apartments, business complexes
Not one for all properties
o “iilarities etee lasses, ake a paret lass so that you do’t hae 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
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents