Topic: Zortech C++ pointers to members


Author: giszter@globus-pallidus.ai.mit.edu (Simon Giszter)
Date: 23 May 92 22:12:59 GMT
Raw View
I have a problem with ZTC++ accessing base class member functions via
pointers to members in the derived class. All args and returns of base
and derived member fuunctions are similar. Code works for a single base class
but with multiple inheritance things break down at the linker.

Example:

class base1
{
public:

void f1(void)
{
cout<<"f1\n";
}
};

class base2
{
public:

void f2(void)
{
cout<<"f2\n";
}
};

class deriv : public base1, public base2
{
public:

void f3(void)
{
cout<<"f3\n";
}


}


main()
{
deriv test;
void (deriv::*tptr) = deriv::f2;


(test.*tptr)();

}

------------------------------------------------------------

This fails at linkage though it passes compile steps. If there is a single
base class the code runs/compiles  ok.
If the first base class function f1 is used code may ralso un ok.

I'm using ZTC 3.02.
(1) Any suggestions or fixes would be appreciated.
(2) Is this legal C++ usage (pointers to base member functions in derived
classes)?

Thanks
Simon G.