Question for C++ Experts

Ryan Sommers ryans at gamersimpact.com
Mon Jul 26 12:51:06 PDT 2004


Pardon my sending this to a FreeBSD list. After searching I couldn't
find any other good mailings lists devoted to C++ and this was the
only source I knew of that might have someone that could answer my
question.

I'm working on a project that uses about 3 different coordinate systems and
all are closely related. The only differences are in the bounds and
representation. As a way to represent all of these I came up with
a base class representing the general case and then derived classes
for all the specific systems. As part of my class I use constructors
that take the coordinates as inputs. As a means of bounds checking
I declared a pure virtual function that checks whether it is within
the valid bounds of the derived class. The problem I am running into
is that it seems to be illegal to call a pure virtual function from
an abstract base contructor. I'm not sure exactly why this would be
considered an eror; from what I can think of the dynamic binding would
be no different than for a binding in a non-constructor function.

Anyone know of any tricks to get around this? Or other methods that might
allow me to do the correct bounds checking in the constructor as opposed
to delaying it to a second 'init' type call?

Ryan Sommers
ryans at gamersimpact.com



More information about the freebsd-hackers mailing list