I'm having a bit of a declarations Problem and I can't seem to get the right order of declarations.
I have a class, "DisplayTree" which represents various things to be drawn on an HDC.
The DisplayTrees are Drawn using an array of functions
DrawDisplayTreeFunctions[] which are not part of the class but are friends with it. And as I need lots of seperate functions to fill the Array I'd rather stow them all away in a namespace.
So Far So Good, I just do this.
Code://Declarations of array Functions in a Namespace namespace nDrawDisplayTreeFunctions { void ArrayFunction1(void); void ArrayFunction2(void); void ArrayFunction3(void); void ArrayFunction4(void); void ArrayFunction5(void); } //Function Array With Functions In it void (* DrawDisplayTreeFunctions[]) (void) = { nDrawDisplayTreeFunctions::ArrayFunction1, nDrawDisplayTreeFunctions::ArrayFunction2, nDrawDisplayTreeFunctions::ArrayFunction3, nDrawDisplayTreeFunctions::ArrayFunction4, nDrawDisplayTreeFunctions::ArrayFunction5 }; class DisplayTree { friend void nDrawDisplayTreeFunctions::ArrayFunction1(void); friend void nDrawDisplayTreeFunctions::ArrayFunction2(void); friend void nDrawDisplayTreeFunctions::ArrayFunction3(void); friend void nDrawDisplayTreeFunctions::ArrayFunction4(void); friend void nDrawDisplayTreeFunctions::ArrayFunction5(void); //Other class members }; namespace nDrawDisplayTreeFunctions { void ArrayFunction1(void) { //Function definition } void ArrayFunction2(void) { //Function definition } void ArrayFunction3(void) { //Function definition } void ArrayFunction4(void) { //Function definition } void ArrayFunction5(void) { //Function definition } }
And That's all Lovely The Array Functions can get at the protected members of the class and they're all tucked away in a namespace where they can't be called willy nilly.
The trouble is I want the functions to take a *DisplayTree as a parameter. Which causes problems, because I have to Declare the Functions inside the namspace before I define the class so I can make them friends. And I have to declare the class before I declare the functions So they can take a *DisplayTree as a Parameter. Can Anyone see a way around this Problem?
help.




Reply With Quote