www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - destructor of non-existing object called

#include <stdio.h>

template<class T>
struct A
{
  A()
  {
    printf("A::A(), this=%08x\n", this);
  }

  A(int i)
  {
    printf("A::A(int), this=%08x\n", this);
  }

  A(const A &a)
  {
    printf("A::A(const A&), this=%08x\n", this);
  }

  A &operator = (const A &a)
  {
    printf("A::operator =(const A&)\n");
    return *this;
  }

  ~A()
  {
    printf("A::~A(%08x)\n", this);
  }
};

int main()
{
  A<int> a = 1;
}


And the output of the program (compiled with DM 8.32.11):

A::A(int), this=406a2e55
A::~A(406a2e55)
A::~A(406a2e54)


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw jabber.at
mailto cmeerw at web.de

...and what have you contributed to the Net?
Dec 14 2002