13.07.2015 Views

29 The Power of Inheritance and Polymorphism

29 The Power of Inheritance and Polymorphism

29 The Power of Inheritance and Polymorphism

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Implementation: Windows classes 1047perimeter points. (<strong>The</strong> input file for the map could define the perimeter as all"wall".)<strong>The</strong> access functions like X(), Y(), Height() etc are all trivial, e.g.:int Window::X() const{return fX;}<strong>The</strong> functions ShowAll() <strong>and</strong> ShowContent() are similar. <strong>The</strong>y have loopstake characters from the current image <strong>and</strong> send the to the WindowRep object fordisplay. <strong>The</strong> only difference between the functions is in the loop limits; functionShowContent() does not display the periphery <strong>of</strong> a framed window.void Window::ShowAll() const{for(int row=1;row 0) && (s < (width-5)))SetLabel(s, label);PrepareContent();ShowValue();}(Note how arguments are passed to the base class constructor.)Function SetLabel() copies the label into the left portion <strong>of</strong> the backgroundimage. Function SetVal() simply changes the fVal data member then callsShowValue().void NumberItem::SetLabel(int s, char * l){fLabelWidth = s;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!