|
CMPT 212
Fall 1997
|
class sentence {
public:
int wordCount() const;
...
private:
int count;
...
};
...
int sentence::wordCount() const {
return count;
}
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) {
}
Return to lecture notes index |
|
| This page is maintained by simpson@cs.sfu.ca. | Last updated on 17 Oct 1997. |