Image

Imagetyrdinjer wrote in Imagecpp

Organizing Code

I've been thinking of reorganizing some code files so that any inline functions are put in a separate header file. This way, the main header file only has declarations. For example, class Foo would have the following files:
Foo.hpp
FooInline.hpp
Foo.c

One way to make sure that FooInline.h is included automatically is put an include in Foo.h, but at the bottom. Thus Foo.h would look like this:

#ifndef FOO_HPP
#define FOO_HPP

#include "whatever_is_needed"

namespace blah {

class Foo
	{};

} // end namespace blah

#include "FooInline.hpp"
#endif


FooInline.hpp would also have an include for Foo.hpp.

Is there any pitfalls that I need to worry about if I organize in this manner?



Edit: fixed a typo pointed out by Imagechocojoshy.