Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


functionpointer to functions in a class

This topic is 5367 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have the following problem: i have a class CAPARSEROPERATORLIST that represents an unordered single linked list which consist of CAPARSEROPERATOR's. these CAPARSEROPERATOR's hold a function pointer, that should point to one of the functiones defined in CAPARSER, for example OperatorPlus or OperatorDiv. (pseudo code) enum CAPARSEROPERATORTYPE { PLUS, MINUS, TIMES, DIVIDE...} class CAPARSEROPERATOR { CAPARSEROPERATOR* mNext; CAPARSEROPERATORTYPE mType; CAFUNCTIONPOINTER mFunction; }; class CAPARSEROPERATORLIST { CAPARSEROPERATOR* mFirstOperator; insert... delete... }; class CAPARSER { public: CAPARSEROPERATORLIST mOperatorList; public: CABOOL OperatorPlus (CAVALUE,CAVALUE); CABOOL OperatorTimes (CAVALUE,CAVALUE); CABOOL OperatorDiv (CAVALUE,CAVALUE); ... }; so my problem: how do i have to define my functionpointer? i mean CAPARSER must know how CAPARSEROPERATOR is defined, because of mOperatorList. so first i have to define CAPARSEROPERATOR and then CAPARSER. now where my problem is: CAFUNCTIONPOINTER is a pointer which points to a function that is in CAPARSER. so before i can define my functionpointer, i should define CAPARSER. do you see my problem? i tried typedef CABOOL (CAPARSER::*CAFUNCTIONPOINTER) (CAVALUE,CAVALUE); at the top of my code before CAPARSEROPERATOR, but it didn't function, because CAPARSER is unknown at this point... [edited by - kudi on February 7, 2004 10:30:10 AM]

Share this post

Link to post
Share on other sites




should do you in your header for CAPARSEROPERATORLIST.

In your header for CAPARSER you include the header for CAPARSEROPERATORLIST.

Then in your header for CAPARSEROPERATOR you include the CAPARSER header and then have the actual declaration of CAPARSEROPERATOR using the definition of CPARSER and its member functions.

[edited by - petewood on February 7, 2004 10:53:21 AM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!