On May 5, 10:28 am, Branimir Maksimovic <bm...@[EMAIL PROTECTED]
> wrote:
> On May 5, 3:03 pm, ".rhavin grobert" <cl...@[EMAIL PROTECTED]
> wrote:
>
> > [insert ya favorite greetin' here;-)]
>
> Hi
>
> > 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()?
>
> It is not called from GetB, therefore does not
> returns there.
> Instead of returning B* directly, return
> object by value that returns B* from overrided operator -> ,
> and place your entry code in constructor, exit code
> in destructor of that object.
Stroustrup wrote a paper about this technique a while ago: "Wrapping C+
+ Member Function Calls": http://www.research.att.com/~bs/wrapper.pdf


|