[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [LC++]Default Arguments
On Fri, 10 May 2002, Mark Phillips wrote:
> Jack Lloyd wrote:
>
>
> > class Y
> > {
> > public:
> > const X* x;
> > void foo() { printf("%d\n", x->foo); }
> > Y(X* xx = new X(42)) : x(xx) {}
> > };
>
>
> Not quite an answer to your question, but...
>
> Wouldn't the above be a memory leak? "X(42)" would not get
> deleted.
Oh. Well yeah, I suppose it would in this case. Presumably real code would
have destructors to delete x. -J