Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 1st, 2005, 7:02 AM   #11
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,206
Rep Power: 5 grumpy is on a distinguished road
Quote:
Originally Posted by stevengs
You know, I generally prefer to list my attributes (private) first too, but every member of the crew at my new place of work unanimously agrees that the methods should be listed first (they are quite nitpicky when it comes to things like that.. sheesh). Not that it is really of much importance, but which is seen more often?
Usually I see public members (and attributes, if any) placed first in a header. The usual reason given is that private/protected members are implementation details, while public members are what is necessary to use the class. And, if more than one person uses the class, it is better to place what they need near the top of the header rather than forcing someone to scroll down through implementation details they aren't interested in.

People who care about the ability of customers to use their class library are often notable for insisting that public members appear near the top of a class declaration. That probably means that people who prefer private members near the top are more concerned with making it easier to modify the class implementation, and less concerned about the impact that has on other people who use their classes.
grumpy is offline   Reply With Quote
Old Jul 1st, 2005, 8:09 AM   #12
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
Quote:
Originally Posted by grumpy
... if more than one person uses the class, it is better to place what they need near the top of the header rather than forcing someone to scroll down through implementation details...
Thanks Grumpy... that makes good sense... the 'interface' to comes first (it suddenly becomes obvious that I have been working alone in a cave all this time..) I reckon I was used to putting private at the top in part due to the fact that it was default and no declaration was necessary. Is that part of the standard, or is that compiler specific? (all these questions.. )
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Old Jul 1st, 2005, 11:12 AM   #13
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
Quote:
Originally Posted by DaWei
"Basically", I wouldn't "utilize" it that way. Those are two of my least favorite words -- one because it's overused and the other because it's worthless. Essentially, I don't use either of them. I feel much better now that I have inputted that :p .
Basically, we are trying to think outside the box here. We want to utilize our resources and implement the new "go-to" strategy and hopefully make a significant impact on the global market.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Jul 2nd, 2005, 11:01 AM   #14
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,206
Rep Power: 5 grumpy is on a distinguished road
Quote:
Originally Posted by stevengs
I reckon I was used to putting private at the top in part due to the fact that it was default and no declaration was necessary. Is that part of the standard, or is that compiler specific? (all these questions.. )
Unless you use modify the access (i.e. use public or protected keywords to override it) everything declared in a class body is private. That is required by the C++ standard.

The only difference between a C++ struct and a C++ class is that, by default, all members of a struct are public and all members of a class are private. Again, this is required by the C++ standard.

The fact that it is (relatively) common practice to place public members near the top of a class declaration is a style guideline. With liberal use of public, protected, and private keywords you can declare class (or struct) members in any order you wish. In other words, the C++ standard allows you to order member functions in a class declaration any way you wish, regardless of how good your approach is according to style guides.
grumpy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:08 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC