Re: How to know the size of my structures/ammount of heap in use?
From: Martin Aupperle (XXXMartin.Aupperle_at_PrimaProgrammXXX.de)
Date: 08/30/04
- Next message: Václav Jedlicka: "Re: Cedit multiline problem - A quite hard one"
- Previous message: Bob Milton: "RE: reboot clear registery settings"
- In reply to: Joseph M. Newcomer: "Re: How to know the size of my structures/ammount of heap in use?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 30 Aug 2004 20:29:51 GMT
On Tue, 24 Aug 2004 15:50:43 -0400, Joseph M. Newcomer
<newcomer@flounder.com> wrote:
>
>The only real distinction, which is syntactic/semantic but not behavioral, is that all the
>members of a struct are implicitly public, unless otherwise stated, and all the members
>of a class are implicitly private, unless otherwise stated.
>
AND, what most people usualy forget, is that default inheritance for
struct is public while for class it is private.
class D : B
means
class D : public B
if B is a struct, and
class D : private B
if B is a class.
[snip]
>That is, there is no meaningful difference. He goes on to say that choice of struct vs.
>class is one of taste. However, I tend to prefer using a class in C++ because it is more
>natural.
Interesting.
For me, the notion
struct Point
{
int x, y
.... // eventually more members
};
is much cleaner than
class Point
{
public:
int x, y;
.... // eventually more members
};
OTOH, I know that many style guides and so called programming gurus
say that classes need to be written with "class". Most of these also
say that all classes need a virtual destructor, an explicit copy
constructor, an explicit assignment operator, and such. Completely
crap.
>Note that there is no implied "more efficient", "more compact", "faster", or any
>other metric in the distinction between struct and class. You may choose to use one or the
>other for esthetic reasons, but don't believe for an instant that they have any other
>meaning in terms of implementation.
There are reasons to write a class with struct resp. class. PODs, for
example, should be written as struct. Classes which maintain state
with their usualy many private members should be written as class.
Other rules exist.
Now, to determine wheter the OP's class should be written with class
or struct, I'd say it is a stateful class and thereforde should be
written as follows:
class Node
{
public:
Node( Node* aParent );
unsigned int getSize() const;
protected: // consider also private here
Node* mParent;
unsigned int mChildCount;
CString mFolder;
};
I don't know how childCount and folder is used, so I did not declare
any functions here.
Hope that helps
Martin
------------------------------------------------
Martin Aupperle
------------------------------------------------
- Next message: Václav Jedlicka: "Re: Cedit multiline problem - A quite hard one"
- Previous message: Bob Milton: "RE: reboot clear registery settings"
- In reply to: Joseph M. Newcomer: "Re: How to know the size of my structures/ammount of heap in use?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|