D
davidzada
Hi guys !
I try to work with application's pointers in c++ , and .. I have some
problems !
I have base class that contain definition of pointer to application.
This application's pointer assigned as argument to another application
that exist in this class.
The definition of the base class look like this:
class Base{
//DB
protected:
typedef int (CTMonitorBase::*pFoo) ();
//api
protected:
void Run(pFoo _apFoo);
};
This base class derived to another class. This class contain
application which suitable to the definition of the application's
pointers.
The definition of the class look like this:
class Inheritor : public Base{
int y1;
int z1;
public:
bool UserFunc(); //another new application.
int zoo(); //suitable to the definition of pFoo pointer.
};
When i try to invoke from UserFunc application to Run application with
the pointer of zoo application
bool Inheritor::UserFunc()
{
Run(zoo);
}
I got the following error:
error C2664: 'void __thiscall Base::Run(int (__thiscall Base::*)(void)'
: cannot convert parameter 1 from
'int (void)' to 'int (__thiscall Base::*)(void)'
None of the functions with this name in scope match the target
type
As i understand the problem is, the Run application can't get the
application's pointer of the Inheritor class, without
casting.
Now, I cast the pointer like this:
bool Inheritor::UserFunc()
{
Run(static_cast<pFoo>zoo);
}
But....
When i try to access in the zoo application to the Inheritor database
(like y1,z1), i read and set to wrong address in the memory.
It seems that the Inheritor class lost its database pointer in the zoo
application.
Any ideas or notes are welcome !
I try to work with application's pointers in c++ , and .. I have some
problems !
I have base class that contain definition of pointer to application.
This application's pointer assigned as argument to another application
that exist in this class.
The definition of the base class look like this:
class Base{
//DB
protected:
typedef int (CTMonitorBase::*pFoo) ();
//api
protected:
void Run(pFoo _apFoo);
};
This base class derived to another class. This class contain
application which suitable to the definition of the application's
pointers.
The definition of the class look like this:
class Inheritor : public Base{
int y1;
int z1;
public:
bool UserFunc(); //another new application.
int zoo(); //suitable to the definition of pFoo pointer.
};
When i try to invoke from UserFunc application to Run application with
the pointer of zoo application
bool Inheritor::UserFunc()
{
Run(zoo);
}
I got the following error:
error C2664: 'void __thiscall Base::Run(int (__thiscall Base::*)(void)'
: cannot convert parameter 1 from
'int (void)' to 'int (__thiscall Base::*)(void)'
None of the functions with this name in scope match the target
type
As i understand the problem is, the Run application can't get the
application's pointer of the Inheritor class, without
casting.
Now, I cast the pointer like this:
bool Inheritor::UserFunc()
{
Run(static_cast<pFoo>zoo);
}
But....
When i try to access in the zoo application to the Inheritor database
(like y1,z1), i read and set to wrong address in the memory.
It seems that the Inheritor class lost its database pointer in the zoo
application.
Any ideas or notes are welcome !