[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: questions about c++ templates
From: Craig Howard <kde () choward ! ca>
Date: 2006-08-19 2:12:37
Message-ID: 200608181912.37119.kde () choward ! ca
[Download RAW message or body]
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<int>::g()
> -08048a1a W Child<int>::pure()
> -0804895a W Child<int>::Child()
> -080489b4 W Child<int>::~Child()
> -0804897c W Child<int>::~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 <iostream>
> >
> > using namespace std;
> >
> > class Base
> > {
> > public:
> > virtual ~Base() {}
> >
> > virtual void pure() = 0;
> > };
> >
> > template<typename T>
> > class Child : public Base
> > {
> > public:
> > virtual ~Child() {}
> >
> > virtual void pure() {}
> > void g() { cout << "T1" << endl; }
> > };
> >
> > int main()
> > {
> > Child<int> c;
> >
> > c.g();
> >
> > return 0;
> > }
> >
> >
> > 12:11:38 [21]; nm -C ./a.out | grep Child
> > 080489ba W Child<int>::g()
> > 080488de W Child<int>::pure()
> > 080488c0 W Child<int>::Child()
> > 0804890a W Child<int>::~Child()
> > 08048988 W Child<int>::~Child()
> > 08048b14 V typeinfo for Child<int>
> > 08048b20 V typeinfo name for Child<int>
> > 08048b00 V vtable for Child<int>
> >
> > 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 <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic