CMPT 212
Fall 1997
|
Read chapter 12 from C++ Primer Plus (2nd ed.), by Stephen Prata. |
class person { public: int getWeight() const; static void setUnits(boolean kilograms); ... private: static bool kgs; ... }; ... person::kgs = true; ... int main() { ... person::setUnits(true); ... person p; cout << p.getWeight(); ... p.setUnits(false); // changes "kgs" for all persons, not just p. ... }
class door { ... }; class tire { ... }; class piston { ... }; class valve { ... }; class engine { piston p[6]; valve v[24]; ... }; class car { engine e; door d[2]; tire t[4]; ... };
Return to lecture notes index |
|
This page is maintained by simpson@cs.sfu.ca. | Last updated on 27 Oct 1997. |