943,772 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 577
  • C++ RSS
Sep 12th, 2007
0

Methods before Members or Members before Methods?

Expand Post »
Methods before Members or Members before Methods?

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.

I know this is all just asthetic. But there must be a set accepted way to do this. What is it? I mean, if you were looking at some sample/example C++ code, how would you expect to see the header files to be written?
Similar Threads
Reputation Points: 17
Solved Threads: 0
Junior Poster
complete is offline Offline
147 posts
since Dec 2005
Sep 12th, 2007
0

Re: Methods before Members or Members before Methods?

I've seen it done both ways -- and even seen people mix them. Myself, I prefer listing methods first.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Sep 12th, 2007
0

Re: Methods before Members or Members before Methods?

>Now I hear that that is wrong and you have to do it the other way.
This is a style issue. If your employer requires it, then their word is law. Otherwise, tell the person who said it was wrong it stuff it and do what you find most comfortable.

>But there must be a set accepted way to do this.
Why? Not everything is black and white. As a programmer you have a slew of options that are all equally good. Just pick one and be consistent with it.

>how would you expect to see the header files to be written?
I would expect them to be written with my style because my style is clearly the best.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Suggests and solution to Histogram program problem please
Next Thread in C++ Forum Timeline: another error need help please!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC