Re: member functions

New Message Reply Date view Thread view Subject view Author view

From: Brian Corrie (bcorrie++at++origin1.imti.nrc.ca)
Date: 05/31/2000 06:19:10


Hi Ken,

We ran into this not too long ago as well... Basically, you have to prevent
the compiler from name mangling the function name you use, as C++ passes in
extra parameters to non-static methods. You need to use a static method.

Here is what you need to do.

In the .h file inside the class do the following:

class Foo
{
        .
        .
        .
  static int preAppCallBack( pfTraverser *trav, void *data );
        .
        .
        .
};

In the .C file

int
Foo::preAppCallBack(pfTraverser *trav, void *data)
{
    // Get a class pointer so we can reference our class. This method is
    // static so it can not access any of the private or protected data
    Foo *fooPointer = static_cast<Foo*>(data);

    // If you need to access the private data, implement another method like
    // this that does the work...
    fooPointer->performAppStuff();

    return PFTRAV_CONT;
}

This was taken out of some code that I was working on yesterday, so I know it
works 8-)

Cheers,

        Brian


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Jun 01 2000 - 12:20:15 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.