在没有任何正式的 IT 教育的情况下学习如何编程,我对许多常见的编程约定几乎视而不见。虽然无关紧要,但这些细节一直困扰着我很长一段时间,如果了解更专业的意见,我会松一口气。
class Bar{};
class Foo
{
public: //Is [public > protected > private] the usual order?
Foo(); //Should constructors and destructors be listed before
void doStuff(void); //..other member functions?
int publicVariable; //Should data members be kept separate from methods?
private:
int x_; //Is there an established order regarding data members?
bool isReady_;
Bar bar_; //Trailing underscore on private class instances?
};