KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When writing a helper method for a class in C++, should it be declared as a private method in the class's definition in the header (.h) file? For example: /*Foo.h*/ class Foo { public: int bar(); private: int helper(); }; ... /*Foo.cpp*/ ... int foo::bar() { int something = this->helper(); } int foo::helper() { ... } Or alternatively, is it better not to declare it as a private member of the class, and instead just make it a free-standing function in the implementation? /*Foo.h*/ class Foo { public: int bar(); }; ... /*Foo.cpp*/ ... int Foo::bar() { int something = helper(); ... } int helper() { ... }
Tags (comma-separated)
Save Edits
Cancel