#ifdef FORWARD_DECLARE class foo; #endif #ifndef NOT_TEMPLATE template #endif class bar { public: friend class foo; // this is not bar::foo, it forward-declares ::foo class foo {}; bar() { foo(); } }; bar #ifndef NOT_TEMPLATE <> #endif baz;