Re: Getting the instance pointer from a called function
From: Elias Athanasopoulos (elathan_at_phys.uoa.gr)
Date: 03/23/04
- Next message: E. Robert Tisdale: "Off Topic: how to scale picture in c++"
- Previous message: Neil Zanella: "Re: polymorphism problem: common signatures with no common parent"
- In reply to: Jonathan Turkanis: "Re: Getting the instance pointer from a called function"
- Next in thread: Julián Albo: "Re: Getting the instance pointer from a called function"
- Reply: Julián Albo: "Re: Getting the instance pointer from a called function"
- Reply: Jonathan Turkanis: "Re: Getting the instance pointer from a called function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 23 Mar 2004 21:38:41 +0200
On Tue, 23 Mar 2004, Jonathan Turkanis wrote:
> "Elias Athanasopoulos" <elathan@phys.uoa.gr> wrote in message
> > Consider I have a Foo class, which ctor's takes as an argument a
> pointer
> > to function, i.e.:
> >
> > Foo *foo = new Foo(bar);
> >
> > Where:
> >
> > int bar(int);
> >
> > bar() will eventually get called somewhen inside Foo (it maybe
> called N
> > times).
> >
> > Now, I want to grab the pointer of Foo's instance (i.e. the 'this'
> > pointer) which called bar(), from inside bar(), when that happens.
>
> Before invoking bar, store a pointer to the current instance of Foo in
> a place where it is accessible to bar, e.g. in a static member, or in
> thread-local storage if you are writing a multithreaded application.
The problem is that I cannot modify Foo. I can have a global array which
will store pointers of Foo instances, but bar() has a strict prototype and
will not be able to identify from which instance is called. bar() has a
per-instance behaviour.
Regards,
Elias
- Next message: E. Robert Tisdale: "Off Topic: how to scale picture in c++"
- Previous message: Neil Zanella: "Re: polymorphism problem: common signatures with no common parent"
- In reply to: Jonathan Turkanis: "Re: Getting the instance pointer from a called function"
- Next in thread: Julián Albo: "Re: Getting the instance pointer from a called function"
- Reply: Julián Albo: "Re: Getting the instance pointer from a called function"
- Reply: Jonathan Turkanis: "Re: Getting the instance pointer from a called function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|