| | |
Methods before Members or Members before Methods?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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?
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?
>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.
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.
I'm here to prove you wrong.
![]() |
Similar Threads
- get/set Methods in java (Java)
- USING CLASSES in VB6 (Visual Basic 4 / 5 / 6)
- I want to let members message each other (PHP)
- Built the site, got members by google adwords, now what? (Growing an Online Community)
- Java editor (Java)
- Need help geting more visitors/members (Growing an Online Community)
- Is There A Way To Protect Members' E-mails From Crawlers and Hackers? (HTML and CSS)
Other Threads in the C++ Forum
- Previous Thread: how to assigned comma and period in a thousand number?
- Next Thread: another error need help please!
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count data delete deploy desktop developer directshow dll download dynamic encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






