Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Jul 2004 13:55:32 -0600 (MDT)
From:      "Ryan Sommers" <ryans@gamersimpact.com>
To:        hackers@freebsd.org
Subject:   Question for C++ Experts
Message-ID:  <49805.208.4.77.15.1090871732.squirrel@www2.neuroflux.com>

next in thread | raw e-mail | index | archive | help
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@gamersimpact.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?49805.208.4.77.15.1090871732.squirrel>