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.
Expand|Select|Wrap|Line Numbers
- 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();
- }
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
Expand|Select|Wrap|Line Numbers
- #undef private
- #define private public
but this unwantedly unveals many non required methods to open arena
plz hlp