Undefined type error even with forward declaration <p>I was reading up on circular references and forward declarations. I do understand that it is not a good design practice to have implementations in a header file. However I was experimenting and could not understand this behavior.</p> <p>With the following code (containing the forward declarations) I expected it to build, however I get this error:</p> <pre><code>Error 1 error C2027: use of undefined type 'sample_ns::sample_class2' </code></pre> <p>Header.hpp</p> <pre><code>#ifndef HEADER_HPP #define HEADER_HPP #include "Header2.hpp" namespace sample_ns { class sample_class2; class sample_class{ public: int getNumber() { return sample_class2::getNumber2(); } }; } #endif </code></pre> <p>Header2.hpp</p> <pre><code>#ifndef HEADER2_HPP #define HEADER2_HPP #include "Header.hpp" namespace sample_ns { class sample_class; class sample_class2{ public: static int getNumber2() { return 5; } }; } #endif </code></pre> <p>Obviously I am missing on something. Can someone point me in the right direction as to why am I getting this error.</p>