Is this possible in C++? toString(ClassName* class)

后端 未结 4 674
天涯浪人
天涯浪人 2021-01-26 05:11

I\'d like to use toString with class argument, but for some reason there is an error. The code is:

Animal.h

#include \"Treatment.h\"
#in         


        
4条回答
  •  借酒劲吻你
    2021-01-26 05:40

    You include Animal.h in Treatment.h before the class Treatment is defined, that's why you're getting the error.

    Use forward declaration to solve this:

    In Animal.h add line

    class Treatment;
    

提交回复
热议问题