Thanks Daniel.
You solved my problem succesfully.
I would like to you ask about situation that I want to have memeber in
struct S, that point to function in class C (not whole class) does it changes
situation? (All other are the same)
struct S
{
//POINTER TO CLASS C MEMBER FUNCTION: IncrementSelectedCount()
};
class C
{
S** items;
private: int selectedCount;
private: void incrementSelectedCount(void)
{
selectedCount++;
}
};
> > Hello
> >
[quoted text clipped - 27 lines]
>
> -cd
MilanB - 23 Jul 2006 11:07 GMT
OK. I Found it.
For other who maybe need same help here is solution:
class MyClass; //Forward declaration
//========================================
struct MyStruct
{
private: MyClass *myClass;
private: void (MyClass::*ptrToMemFunction)();
public: void CallFunction()
{
//Calling member function from referenced class
(myClass->*ptrToMemFunction)();
}
//On costructor pass Class and Function Member pointer
public :MyStruct(MyClass *parMyClass, void (MyClass::*parPtrToMemFunction)())
{
MyStruct::myClass = parMyClass;
MyStruct::ptrToMemFunction = parPtrToMemFunction;
}
//========================================
class MyClass
{
private: void memberFunction(void)
{
//do something
}
//Pass references..
private: void addNew(...) //some function...
{
.
.
.
void (MyClass::*ptrToMemberFunction)() = memberFunction;
MyStruct myStruct = new MyStruct(this, ptrToMemberFunction);
//Now we have struct that have valid pointer to MyClass::memeberFunction
.
.
}
};
Regards
Milan