is there a standard in order of functions in cpp file?
there are:
in cpp file, is there any good way to order?
i order them as i wrote in the list above.
i know that it does not change anything but i care about good looking code...
how do you order?
my personal order is given by the order inside the class declaration:
class MyClass
{
public:
MyClass();
~MyClass();
void start();
protected:
static void init(MyClass *);
private:
int m_iCounter; ///< counter variable for....
};
would look like this in .cpp:
MyClass::MyClass() :
m_iCounter(0)
{
...
}
MyClass::~MyClass() {
...
}
void MyClass::start() {
...
}
void MyClass::init(MyClass *) {
...
}
The order is defined as followed:
signals
start()
and stop()
, then getters and settersHope that helps.
ciao, Chris
This may seem silly, but I try to order my public methods by "order of 'normal' use", so constructors come first, then public doStuff methods, then close methods... the exception to this "rule" is the ~destructor, which comes after the last constructor.
Last comes any private "helper" methods.
I use this same approach in all languages... (C++, Java, C#, Perl, sh, or whatever) and nobody has actually shot-me for it (yet).
Cheers. Keith.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With