From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,85c4b961f840b5ab X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.news.ucla.edu!newsfeed.media.kyoto-u.ac.jp!Spring.edu.tw!news.nctu.edu.tw!feeder.seed.net.tw!attdv1!ip.att.net!newsfeed1.global.lmco.com!svlnews.lmms.lmco.com!not-for-mail From: "Xenos" Newsgroups: comp.lang.ada Subject: Re: Zero length Objects Date: Thu, 1 Jul 2004 11:03:14 -0400 Organization: Hades Message-ID: References: <2oUEc.2$S77.1@nwrdny03.gnilink.net> <2kimpdF2orakU1@uni-berlin.de> NNTP-Posting-Host: 158.187.64.144 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Xref: g2news1.google.com comp.lang.ada:2029 Date: 2004-07-01T11:03:14-04:00 List-Id: "Nick Roberts" wrote in message news:2kimpdF2orakU1@uni-berlin.de... > To my mind, a significant problem remains. If we declared something like: > > CWhatever mem_a[1000000]; > > somewhere in a template class, where CWhatever was a template parameter, and > then instantiated the class with CEmpty replacing CWhatever, we would get a > mem_a in the instance that took up a whopping amount of memory to store > absolutely nada! Yuk. > > PS: Please forgive any minor mistakes, I'm not a C++ expert. > > -- > Nick Roberts > > But C++ does compensate for this somewhat. Empty base classes (used for traits and the like) will not take any space in derived classes. For example: class Empty {}; class Derived : public Empty { char a; }; Derived D[1000000]; Here, Empty is not increase the size of D at all. DrX