search

Home  >  Q&A  >  body text

In C++, the problem of implementing inheritance polymorphism

In the header file, the inherited base class always reports an error when compiling: expected class-name before '{' token

某草草某草草2696 days ago1224

reply all(3)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-27 09:21:06

    I feel this has nothing to do with inheritance, it’s just that you wrote the code wrong

    reply
    0
  • 代言

    代言2017-06-27 09:21:06

    It should be that your code is written wrong. You can post the code so that I can help you analyze it in detail

    #ifndef MAN_H 
    #define MAN_H 
    #include "person.h"
    class Man :public person
    {
    public:
        Man();
        void helpForOthers();
    };
    
    #endif//MAN_H
    
    int main()
    {
        return 0;
    }

    This should be fine

    reply
    0
  • 高洛峰

    高洛峰2017-06-27 09:21:06

    reply
    0
  • Cancelreply