Re: Detecting pointer on the heap
On 03.04.2010 00:03, James Kanze wrote:
On Apr 1, 3:04 pm, Goran<goran.pu...@gmail.com> wrote:
On Mar 31, 9:39 pm, pfultz2<pful...@yahoo.com> wrote:
There is NO "neater way" but to KNOW, at any point in your
code, what you need to do with any object/variable.
Note that in practice, most types will either be always
allocated dynamically, or never allocated dynamically. There
are exceptions, but they aren't that frequent.
You got that the wrong way round. In therory most types in a given prg
environment should be of the kind to either be used dynamically or not.
In *practice* it will be a muble jumble of different styles and weird
constructs.
// My favourite I-have-been-a-Java-programmer snippet:
{
Obj* o = new Obj(...);
...
o->foo();
...
if(o) delete o; // yes, I know, the if is useless
}
Of course, I don't think that's a reason to require any function that
determines where a pointer belongs.
cheers,
Martin
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]