www.digitalmars.com         C & C++   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