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

后端 未结 7 1503
暖寄归人
暖寄归人 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 14:52

    Try this new source :

    student.h

    #include 
    
    struct Student {
        std::string lastName;
        std::string firstName;
    };
    

    student.cpp

    #include "student.h"
    
    struct Student student;
    

提交回复
热议问题