C++, how to declare a struct in a header file

后端 未结 7 1502
暖寄归人
暖寄归人 2021-01-30 14:40

I\'ve been trying to include a structure called \"student\" in a student.h file, but I\'m not quite sure how to do it.

My student.h file code c

7条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 15:04

    You should not place an using directive in an header file, it creates unnecessary headaches.

    Also you need an include guard in your header.

    EDIT: of course, after having fixed the include guard issue, you also need a complete declaration of student in the header file. As pointed out by others the forward declaration is not sufficient in your case.

提交回复
热议问题