I have a class A
Defind like this
Expand|Select|Wrap|Line Numbers
- class A
- {public:
- const ClassB &bInstance;
- void function();
- }
Expand|Select|Wrap|Line Numbers
- class ClassB
- {
- public:
- void publish();
- }
If i want to use the bInstance....How can i use....
i tried like this....
Expand|Select|Wrap|Line Numbers
- void A::function()
- {
- bInstance.publish();
- }
Soooo I changed the code like this...
Expand|Select|Wrap|Line Numbers
- void A::function()
- {
- ClassB *temp=(ClassB*)&bInstance;
- temp->publish();
- }
And it worked...But i want to know the exact reason....please someone help....