Forward Declaration of a Base Class

前端 未结 6 641
旧巷少年郎
旧巷少年郎 2020-12-10 01:57

I\'m trying to create proper header files which don\'t include too many other files to keep them clean and to speed up compile time.

I encountered two problems while

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 02:42

    For your base classes, you need to have the full type definition, not just a declaration. Derived type headers will need to #include the header for their base classes.

    For classes in the std namespace, you must include the proper header - in this case - and then do one of 3 things:

    1. Fully qualify the type: std::string aStringToTest

    2. Put a using declaration for just that type: using std::string;

    3. Put in a using declaration for the std namespace: using namespace std;

提交回复
热议问题