listhelper-moderate
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

help-gplusplus post from address@hidden requires approval


From: help-gplusplus-owner
Subject: help-gplusplus post from address@hidden requires approval
Date: Wed, 04 Jul 2007 12:40:17 -0400

As list administrator, your authorization is requested for the
following mailing list posting:

    List:    address@hidden
    From:    address@hidden
    Subject: lifetime of temporaries
    Reason:  Post by non-member to a members-only list

At your convenience, visit:

    http://lists.gnu.org/mailman/admindb/help-gplusplus
        
to approve or deny the request.
--- Begin Message --- Subject: lifetime of temporaries Date: Wed, 04 Jul 2007 15:55:34 -0000 User-agent: G2/1.0
I have the following program:

class A
{
  string s;

  public:
  A(const string& a) : s(a) { cout << s << endl; }

};


class B : public A
{
  public:
  B(const string& b) : A(b) { }
};

class C : public B
{
  public:
  C() : B(string("ABC")) { }
};

int main(int argc, char *argv)
{

unsigned char i = 0;

C* c = new C;

delete c;
}
/////////////////////////////////////////////////////////

If I put the delete c statement in comment, valgrind will report that
I'm leaking c AND the string temporary created when invoking B ctor.
why ?

I would have expected that the temporary would be destroyed after c
was created, not haning there until I destroy c.


--- End Message ---
--- Begin Message --- Subject: confirm f87ce7033ff1d8750f09f2e64abfffcd27e8c06a
If you reply to this message, keeping the Subject: header intact,
Mailman will discard the held message.  Do this if the message is
spam.  If you reply to this message and include an Approved: header
with the list password in it, the message will be approved for posting
to the list.  The Approved: header can also appear in the first line
of the body of the reply.

--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]