Class has no member named

前端 未结 9 1202
甜味超标
甜味超标 2021-02-19 01:00

I have a problem with accessing a function from a class with the class object in my main function. I am just trying to make the object for the class and use that ob

9条回答
  •  死守一世寂寞
    2021-02-19 01:31

    Try to define the functions right into the header

     #ifndef ATTACK_H
     #define ATTACK_H
    
     class Attack {
         public:
             Attack(){};
             void printShiz(){};
         protected:
         private: };
    
     #endif // ATTACK_H
    

    and to compile. If the compiler doesn't complain about duplicate definitions it means you forgot to compile the Class.cpp file, then you simply need to do it (add it to your Makefile/project/solution... which toolchain are you using?)

提交回复
热议问题