Even the simplest class doesn't compile, "has not been declared

后端 未结 2 412
天涯浪人
天涯浪人 2021-01-22 19:49

OK, this is really annoying. I have the (almost) simplest class possible. Two files: a.cpp and a.h a.h:

#ifdef A_H
#define A_H
class a{
  public:
    a();
};
#en         


        
2条回答
  •  清酒与你
    2021-01-22 20:23

    Its because

     #ifdef A_H
    

    needs to be

     #ifndef A_H
    

    notice the "n", as in if NOT defined.

    The former will only compile the code if A_H is defined, which it isn't since you only define it on the next line.

提交回复
热议问题