Single class has a Class Redefinition Error

后端 未结 4 1095
眼角桃花
眼角桃花 2021-01-04 19:00

I\'m new to C++, and I\'m having a problem with my class definitions in a header file. The code for the header file (Student.h) is:

#include 
u         


        
4条回答
  •  被撕碎了的回忆
    2021-01-04 19:53

    When I learnt c++ our professor said, the first two lines that you write in c++ class should always be #ifndef followed by #define. This prevents multiple definitions in header files

    http://www.fredosaurus.com/notes-cpp/preprocessor/ifdef.html

提交回复
热议问题