|
|
![]() |
|
|
Top | #1 |
|
OSNN Addict
Joined: August 2005
Posts: 94
Reputation: 10
Power: 83 |
In a header file, which do you define/declare first. Do you list all your variables before the methods (also known as functions), or do you do it the other way around? I always thought that you put the variables first. That was the way I was taught in school. Now I hear that that is wrong and you have to do it the other way. I am told you should list the methods first. |
|
|
|
|
|
Top | #2 |
|
Penguin Rancher
Joined: February 2002
Location: Elizabethton, TN
Posts: 280
Reputation: 180
Power: 129 |
I define private members and private methods first. Then, I define all my public accessor methods. For me, classes are much easier to navigate that way. Attributes are listed before methods on UML class diagrams too.
Basically, it is just preference. If your development house (or school) has a coding standard, you should follow whatever the standard states. The compiler isn't going to care. It will optimize your code. I am not aware of any advantage. |
|
|
|
|
|
Top | #3 |
|
*
Joined: December 2001
Location: USA
Posts: 6,496
Reputation: 2808
Power: 220 |
Public
Private Protected Unless I need to have a variable that is protected available for a public function, in which case I tend to do Private Protected Public for classes, as for functions vs variables variables functions |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| methods for WBXML decoding | sachinjain_30 | Portable Devices & Gadgets | 0 | October 5th, 2006 4:17pm |
| Java Methods | PseudoKiller | Web Design & Coding | 20 | March 31st, 2004 2:26am |
| Backup methods? | jkoXP | Windows Desktop Systems | 5 | September 16th, 2003 10:51pm |
| Other Methods With Ramdisk!?? | Hercules | Windows Desktop Systems | 2 | April 13th, 2002 11:13pm |