Say if we ve certain private methods along with private data members and public methods.
other than friend function is thr any other way we access these members(they being private only) directly. its one of the requirements in a project of mine.
The real prob comes when accessing function.
say we've classes ported to us in .obj format. then going for DMA using pointers is a risky n unreliable job.
class x
{
private:
void meth1()
{
cout<<"Meth1";
}
void meth2()
{
cout<<"meth 2";
}
};
class xduplicate
{
public:
void virtual meth1();
void virtual meth2();
};
main()
{
x obj;
xduplicate *obj1;
obj1=(xduplicate *)&obj;
obj1->meth1();
}
we can access meth1 only if in class x it is virtual. i.e. the entry is in the virtual table.
But now i cant jst change the native code ported to us. i've to anyhow access the private methods without any change in native code.
wht we're plannin is x will be the producer class n xduplicate the consumer class.
x will be available as .obj along with .h file
so how can 1.
though one of the cheap n unprofesssional sol is
#define private public
but this unwantedly unveals many non required methods toopen arena
plz hlp