From: Charles Krug Newsgroups: comp.os.msdos.djgpp Subject: Re: Structures vs. Classes Date: Thu, 11 Mar 1999 09:34:40 -0500 Organization: Pentek Corporation Lines: 27 Message-ID: <36E7D47F.9452268C@pentek.com> References: <36E6768B DOT 6C91860E AT xyz DOT net> NNTP-Posting-Host: mail.pentek.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mozilla 4.5 [en] (WinNT; U) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Bjørn Hansen wrote: > This is really a general C++ question but I don't read any other > newsgoup So. . . > > Anyway is there any reason to use a structure instead of a class in C++? If you're doing c++, and especially if you're like me and change from c to c++ depending upon which day it is, you have to adjust your thinking from "c-mode" to "c++-mode." In c, a structure is a structure, you know it, you love it--it's familiar. In c++, what we call a structure is REALLY a class whose members are public be default. It's a subtle change, true, but an important one. For example, the scope resolution operator, member functions all are valid things to do with structures in c++. I minimize confusion on my part (since I'm usually the guy who has to fix things), by only using structures when I want them to be EXACTLY the same as c structures--no member functions, only public data, and use classes for everything else. That works for me, buy YMMV. Charles