i take it is
private:
then
public:
but is it methods or members first
Printable View
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.
It's individual preference. I do public, protected, constructors, destructors, operators, member functions, variables.
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.
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
};