Interesting question (at least to me :) ). I like to keep the classes in my C++ project somewhat like Java (with just one class per file), and a header file to that class:
wheel.hpp
#ifndef _WHEEL_HPP_
#define _WHEEL_HPP_
class C_Wheel {
private:
bool isEnabled;
public:
bool getIsEnabled();
};
#endif
wheel.cpp
#include "wheel.hpp"
// ctors and dtor
bool C_Wheel::getIsEnabled() {
return isEnabled;
}
This raises two questions:
1- Is this a good pratice? What is the pros and cons of such approach?
2- As I don't want to declare nothing in the headers (methods are inlined by default), how do I inline methods declared in the cpp file? Is it possible? I've read that YES (http://www.cs.utexas.edu/users/downing/cs378/Elements/Methods.html), using "inline boll C_MyClass::getIsEnabled()" in the cpp, but Visual C++ 6 drops a "error LNK2001: unresolved external symbol 'public: void __thiscall C_Wheel::roll(float)'".
Thanks!!