#ZTC v2 and old cols
4 messages in this thread
Al – I have been trying to pick up C++, and have found your column helpful.
Recently I upgraded to the Zortech C++ version 2 compiler, and found that
some of your programs published in the fall will no longer compile. (No
problem with version 1.07.) I've been able to make most of the changes
needed, but am running into run time problems (pointers) with demopop in
the Oct. '89 issue.
The code in menus.c) for the PopDownMenu class overloaded operator << and
for the get_selection method (also in the PopDownMenu class) get compile
errors when making assignments to several of the self-referencing pointers
this. (Sorry if I got the jargon wrong. It's not easy going.)
Have you upgraded compilers? I'd like to see what the fix is.
Thanks – EF -n menus.cxe
EricF,
Sorry, I do not have the new Zortech.
Al Stevens
Hmmm… I asked the people at Zortech to send you a copy. Looks
like it fell in the cracks. I'll see what I can do.
— MF
You can't assign to `this'. The type of `this' in a member function of a
class X is (X *const this), so you can see that an assignment will in fact
cause an error, "attempt to assign to a const object". see the reference
manual paragraph 9.3.1.
I suggest you change code like:
while (this) {
//do stuff
this= next;
}
into:
X* tthis= this;
while (tthis)….
that is, define a new, non-const variable at the top of the function and
assign it the same pointer, and proceed to use that one. Problem is your
references to members will then need to be qualified tthis->next for
example.
–John