Topic: pointer to C++ methods - is this valid?


Author: bmcphers@alias.com (Brent McPherson)
Date: Thu, 30 Jan 1992 21:59:40 GMT
Raw View
I have a smart callback class in C++ that maintains a pointer to an
object and a pointer to a method.

The class looks something like this:

extern class SomeClass;
class CallbackSomeClass {
private:
 SomeClass * object; // This declaration is OK.
 void  (SomeClass::*method)(int parm); // This is the problem
public:
 // constructors, apply method etc.
};

On most compilers I have dealt with, this compiles fine (MPW/CFront/Zortech)
but on one particular compiler this declaration of a pointer to a
method is flagged as an error because class SomeClass has been
"declared but not defined".  To me this seems like a compiler bug
but I am not familiar enough with the ARM to find out if this is
acceptable compiler behaviour.

By disallowing this, the compiler has prohibited me from using
method pointers in a circular fashion.  In other words, I cannot
declare a class A that contains a pointer to a method of class B
and class B that contains a pointer to a method of class A.

Wasn't the "extern class" construct added to C++ so this sort of
circular reference could be made possible with class pointers?

Any help I can get in convincing the compiler vendor that this is
a bug (or at the very least should be a warning instead of an error)
is greatly appreciated.  I personally consider it a bug that makes
the compiler unacceptable since it breaks alot of existing C++ code.

Note: the compiler/company shall remain nameless since it is a
   beta version of the compiler and I have signed an NDA with
   the compiler vendor.

Thanks in advance!
--
Brent McPherson  (bamcpherson@alias.com)
Alias Research Inc. Toronto, Canada.