i take it is
private:
then
public:
but is it methods or members first
i take it is
private:
then
public:
but is it methods or members first
Typically, I'll do public, protected, and private, with constructors, functions and data members within these groups.
It's up to each person's personal preference, but I find that this order makes it easier when using header files as documentation.
I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo
I think it's a good idea to put the interface first so that other developers can quickly find what they need. In other words, what Elysia wrote.
I usually put all my member variables at the top, then public, protected & private functions; but if you have a good IDE it probably doesn't matter since you can see the list of member variables & functions on the side bar anyways.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
In C++, the pattern I use is:
Code:class Foo { public: public types (if any: enums, nested classes) constructors destructor accessors public methods public variables (if any, rare) protected: protected constructor (if any) protected methods protected variables (if any, rare) private: friend declarations (if any) private types (if any: enums, nested classes) private constructor (if any) private methods private variables };
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}