cc-july5

cc-july5 - CS 246 (Spring 2011) Comments and corrections...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 246 (Spring 2011) Comments and corrections for Tues July 5 (Section 001) ====================================================== Example on Slide 8 ------------------ Here is the example that I didn't do in lecture. In our running example, add the following definition of the assignment operator in Game: // define the assignment operator to only change the name // of the game, but keep all other members the same cout << "assignment operator in Game" << endl; name = rhs.name; } and add the following copy constructor to ElectronicGame: // this copy constructor does not change any members cout << "copy constructor in ElectronicGame" << endl; } Update the code on the slide to be: Game g("Hangman", 2, 1.99, 3); Game g2 = g; Game g3; cout << "g2 name: " << g2.getName() << endl; cout << "g2 rating: " << g2.getRating() << endl; cout << "g3 name: " << g3.getName() << endl; cout << "g3 rating: " << g3.getRating() << endl;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/08/2011 for the course CS 246 taught by Professor Wormer during the Spring '08 term at Waterloo.

Page1 / 2

cc-july5 - CS 246 (Spring 2011) Comments and corrections...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online