Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: calling "af...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 6 Topic 45758 of 47031
Post > Topic >>

Re: calling "after return"...?

by gw7rib@[EMAIL PROTECTED] May 5, 2008 at 07:31 AM

On 5 May, 14:03, ".rhavin grobert" <cl...@[EMAIL PROTECTED]
> wrote:
> guess you have the following cl*****...
> ___________________________________
> class =A0{
> =A0 //..a couple of methods ...//
>
> };
>
> class A {
> public:
> =A0 //...//
> =A0 B* GetB() // <- this we'll talk about
> private:
> =A0 B* m_pB;
>
> };
>
> A::GetB() {
> =A0 //..some code..//
> =A0 return m_pB;};
>
> ___________________________________
>
> when some does a...
>
> A.GetB()->AMethodOfB();
>
> ... and you want some code be executed before B::AMethodOfB() is
> called, you simply pack it into A::GetB()'s body before the return.
> But what do yuo do, if you want to execute some code _after_ B's
> method is executed, e.g. when the callstack - after completing the
> call into B - returns back into A::GetB()?

Possibly your best bet would be to replace GetB with a function to
call a method of B. Eg something like:

void A::callB(int fun) {
switch (fun) {
  case METHODA: m_pB -> firstmethod(); break;
  case METHODB: m_pB -> secondmethod(); break; }
doafterstuff();
}

For more advanced stuff, function pointers might help.

Hope this helps.
Paul.
 




 6 Posts in Topic:
calling "after return"...?
".rhavin grobert&quo  2008-05-05 06:03:07 
Re: calling "after return"...?
Branimir Maksimovic <b  2008-05-05 07:28:40 
Re: calling "after return"...?
gw7rib@[EMAIL PROTECTED]   2008-05-05 07:31:11 
Re: calling "after return"...?
Ben Bacarisse <ben.use  2008-05-05 15:42:18 
Re: calling "after return"...?
pjb@[EMAIL PROTECTED] (P  2008-05-05 16:53:12 
Re: calling "after return"...?
"Eric.Malenfant@[EMA  2008-05-05 07:56:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 15:36:08 CDT 2008.