Dear Ladies and Gentlemen,
THE DUE DATE FOR HOMEWORK #5 IS EXTENDED TILL
MONDAY, AUGUST 5, 4:30 PM.
Thanks to care of our excellent reader, Mr. C. Amor, it was
brought to my attention that in some of the code samples for
PIC 10B I had a misfortune to use a feature not supported by
ANSI C++ standard (and therefore not supported by the
majority of compilers).
Namely, although calling one constructor from another
constructor of the same class does not produce compile-time
error, but it does not do anything useful either - such a
call does not initialize an object as I intended.
Luckily it is really trivial to fix this issue. In all
cases where this error appeared, instead of two constructors
(one general and the other default "noargs"), one can use a
single constructor with default argument. I will illustrate
this on example of ListElmt
class and List
class defined in files list.h
and list.cpp
.
--- OLD VERSION OF ListElmt CLASS: ------
class ListElmt {
public:
ListElmt(const void *data) {
this->data = (void *) data;
next = NULL;
}
ListElmt() {
ListElmt(NULL);
}
...
};
--- CORRECTED VERSION OF ListElmt CLASS: ---
class ListElmt {
public:
ListElmt(const void *data = NULL) {
this->data = (void *) data;
next = NULL;
}
...
};
---------------------------------------------
---------------------------------------------
--- OLD VERSION OF List CLASS: -----
class List {
public:
List(void (*destroy)(void *data));
List();
...
};
...
List::List(void (*destroy)(void *data)) {
size = 0;
head = NULL;
tail = NULL;
this->destroy = destroy;
}
List::List() {
List(NULL);
}
...
--- CORRECTED VERSION OF List CLASS: ---
class List {
public:
List(void (*destroy)(void *data) = NULL);
...
};
...
List::List(void (*destroy)(void *data)) {
size = 0;
head = NULL;
tail = NULL;
this->destroy = destroy;
}
...
--------------------------------------------------
--------------------------------------------------
As you can see, in each case a pair of constructors
is replaced with a single constructor with default
argument value. In addition to ListElmt and List,
analogous changes are done to the following classes:
Stack, Queue, CHTbl, BiTreeNode, BiTree. I am
terribly sorry for any inconvenience.
This mistake should not have affected your solution
to homework #4, but it might have affected homework #5.
Because of this,
THE DUE DATE FOR HOMEWORK #5 IS EXTENDED TILL
MONDAY, AUGUST 5, 4:30 PM.
I hope that this will give you enough time to incorporate
required small changes in your source files.