Re: off-topic: C++/new

New Message Reply Date view Thread view Subject view Author view

Jim Helman (jim++at++liberate.com)
Wed, 20 Oct 1999 10:21:01 -0800


There are actually three cases: new, static and automatic (stack).

If you overload the new operator on a per-class basis, that new
operator could signal the constructor, e.g. by setting a data member
in the class.

Distinguishing the latter two is trickier. I suppose you could have
the constructor compare "this" to the address of a stack variable to
see if it looks like a stack address.

I've seen worse hacks.

-jim

Jim Helman
jim++at++liberate.com
650.701.4638

On Mon, 11 Oct 1999 "Dirk Scheffter" wrote:

> Hi there,
>
> it's rather off-topic but I need it in my pfApp...
>
> If a constructor of a C++ class is executed: Is it possible to
> recognize how it was created? (I mean either statically or
> dynamically using new?)
>
> Would it help to overload operator new?
>
> All help is appreciated?
>
> Greetings,
> Dirk.


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Wed Oct 20 1999 - 11:22:07 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.