![]() |
CMPT 212
Spring 1998
|
const int i = 3; const sentence one("hello"); sentence two; two.appendWord("this"); two.appendWord("is"); two.appendWord("a"); two.appendWord("test"); const sentence three(two);
class sentence { ... private: const int maxLength; ... };
class sentence { public: sentence(); ... private: const int maxLength; char * words; int count; }: sentence::sentence() : maxLength(10), words(NULL), count(0) { // body is now empty. }
class myClass { public: myClass(); myClass(char * w); myClass(char * a, char * b); ... private: sentence one; sentence two; ... }; myClass::myClass() { } myClass::myClass(char * w) : one(w) { } mytClass::myClass(char * a, char * b) : one(a), two(b) { }
Point * p = new Point; p->move(3.0, 4.0); p->display(); delete p;
Point * p = new Circle; p->move(3.0, 4.0); p->display(); // which "display" function? delete p;
![]() Return to lecture notes index |
|
This page is maintained by simpson@cs.sfu.ca. | Last updated on 23 Feb 1998. |