Re: Returning reference to pointer
On Feb 19, 10:38 pm, "jason.cipri...@gmail.com"
<jason.cipri...@gmail.com> wrote:
On Feb 19, 3:23 pm, Haquejiel <Haquej...@gmail.com> wrote:
I was unsure of if the value was getting deleted or not, and the
deconstruction was throwing me off a bit.
This doesn't deal with your problem specifically but I've been
in similar situations. One technique I've found useful for
these kinds of things is printing the value of 'this' in your
debugging statements:
struct Object {
Object (void) { cout << this << ": constructed" << endl; }
~Object (void) { cout << this << ": destructed" << endl; }
};
Also, when you do this, be sure to either inhibit copy and
assignment, or provide instrumented versions of those as well.
Had the OP instrumented copy as well, he would have seen
immediately what was happening.
(I've not got it in my library yet, but on occasion, I've used a
macro along the lines of:
#define instrument( f ) \
std::cerr << # f << ": " << this << std::endl
Saves a little bit if typing:-). And in large projects, of
course, every function will be instrumented anyway, using the
project's standard logging mechanism.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34