From kde-devel Sat Aug 19 02:12:37 2006 From: Craig Howard Date: Sat, 19 Aug 2006 02:12:37 +0000 To: kde-devel Subject: Re: questions about c++ templates Message-Id: <200608181912.37119.kde () choward ! ca> X-MARC-Message: https://marc.info/?l=kde-devel&m=115595371617020 On Friday 18 August 2006 14:09, Kleag wrote: > Well, with this code, templates have no influence, at least for nm: with or > without them, there is no difference except for addresses. Right, but that's significant, because Child::pure() wasn't referenced, so it shouldn't have been created. Or so I thought. > -0804894a W Base::Base() > +080489ee W Base::Base() > 08048920 W Base::~Base() > 080488f6 W Base::~Base() > 080488cc W Base::~Base() > -080489ec W Child::g() > -08048a1a W Child::pure() > -0804895a W Child::Child() > -080489b4 W Child::~Child() > -0804897c W Child::~Child() > +080489c0 W Child::g() > +080489ba W Child::pure() > +080489fe W Child::Child() > +08048982 W Child::~Child() > +0804894a W Child::~Child() > > Regards, > > Kleag > > Le vendredi 18 août 2006 21:13, Craig Howard a écrit : > > On Friday 18 August 2006 11:03, Frans Englich wrote: > > Interesting. You are correct: > > > > #include > > > > using namespace std; > > > > class Base > > { > > public: > > virtual ~Base() {} > > > > virtual void pure() = 0; > > }; > > > > template > > class Child : public Base > > { > > public: > > virtual ~Child() {} > > > > virtual void pure() {} > > void g() { cout << "T1" << endl; } > > }; > > > > int main() > > { > > Child c; > > > > c.g(); > > > > return 0; > > } > > > > > > 12:11:38 [21]; nm -C ./a.out | grep Child > > 080489ba W Child::g() > > 080488de W Child::pure() > > 080488c0 W Child::Child() > > 0804890a W Child::~Child() > > 08048988 W Child::~Child() > > 08048b14 V typeinfo for Child > > 08048b20 V typeinfo name for Child > > 08048b00 V vtable for Child > > > > Does anybody know why that is? And why there are two destructors for > > Child? -- Craig Howard craig@choward.ca Software Engineer - Amazon.com BMath CompSci - University of Waterloo >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<