EngineersForge
Technical User
Ok thank you for the samples; however, I am still at a loss.
Here is another attempt:
calss a
{
public:
void (*fpReqSer) (void);
void RequestService(void);
};
void a::RequestService(void)
{
//raise event
fpReqSer();
}
NOW
class b: public a
{
whatever...
};
NOW
void service1(void){print some stuff out};
void main(void)
{
b Foo;
Foo.fpReqSer = &Service1;
pod.RequestService();//works just fine
b Foo1(Foo);
Foo1.RequestService();//access violation ???
}
I think the problem must be int he copy constructor impl.
HERE IT IS
a::a(const a &rhs)
{
//one of
*fpReqSer = *rhs.fpReqSer; // (1
fpReqSer = **rhs.fpReqSer; // (2
fpReqSer = (*rhs.fpReqSer)(); // (3
fpReqSer = (rhs::*fpReqSer)(); // (4
}
1) just sinc. the pointers??? It don't work! access violation at runtime.
2) because rhs is a reference??? don't work! access violation at runtime.
3) it complies, but don't work??? access violation at runtime.
3) for some reason complier doesn't recognize rhs as a class or a namespace???
There are other combinations that compile but will not run. Interesting thing is that they all send the IP to the same no-where address (0xcccccccc). I just can't see why one can't copy a pointer to a function from another class type of the same kind.
Could this be a VS C++ thing potentially used to call libraries and disassemble them to hack the code????
tanx
Here is another attempt:
calss a
{
public:
void (*fpReqSer) (void);
void RequestService(void);
};
void a::RequestService(void)
{
//raise event
fpReqSer();
}
NOW
class b: public a
{
whatever...
};
NOW
void service1(void){print some stuff out};
void main(void)
{
b Foo;
Foo.fpReqSer = &Service1;
pod.RequestService();//works just fine
b Foo1(Foo);
Foo1.RequestService();//access violation ???
}
I think the problem must be int he copy constructor impl.
HERE IT IS
a::a(const a &rhs)
{
//one of
*fpReqSer = *rhs.fpReqSer; // (1
fpReqSer = **rhs.fpReqSer; // (2
fpReqSer = (*rhs.fpReqSer)(); // (3
fpReqSer = (rhs::*fpReqSer)(); // (4
}
1) just sinc. the pointers??? It don't work! access violation at runtime.
2) because rhs is a reference??? don't work! access violation at runtime.
3) it complies, but don't work??? access violation at runtime.
3) for some reason complier doesn't recognize rhs as a class or a namespace???
There are other combinations that compile but will not run. Interesting thing is that they all send the IP to the same no-where address (0xcccccccc). I just can't see why one can't copy a pointer to a function from another class type of the same kind.
Could this be a VS C++ thing potentially used to call libraries and disassemble them to hack the code????
tanx