C++ C++;对象创建错误向量

C++ C++;对象创建错误向量,c++,C++,我试图给程序中的每个“Person”对象一个“Record”对象向量。然而,我得到了一个错误:“记录未在此范围内声明”用于我的向量创建。我的Record.cpp和.h文件在同一个src文件夹中。不确定出了什么问题。我必须在Person.h文件中包含Record.h吗?代码如下: #ifndef PERSON_H #define PERSON_H #include <string> #include <vector> #include <ctime> cl

我试图给程序中的每个“Person”对象一个“Record”对象向量。然而,我得到了一个错误:“记录未在此范围内声明”用于我的向量创建。我的Record.cpp和.h文件在同一个src文件夹中。不确定出了什么问题。我必须在Person.h文件中包含Record.h吗?代码如下:

#ifndef PERSON_H
#define PERSON_H
#include <string>
#include <vector>
#include <ctime>



class Person
{

private:

    //id, age, name, and date of Person object creation shall be assigned in constructor. The vector 'log' shall be empty at start. 
    int id; 
    int age; 
    std::string name; 
    std::vector<Record> log;
    time_t t;
    struct tm * timeStruct;

public:
    Person();
    ~Person();

};

#endif // PERSON_H
\ifndef PERSON\u H
#定义人
#包括
#包括
#包括
班主任
{
私人:
//应在构造函数中指定Person对象创建的id、年龄、姓名和日期。向量“log”在开始时应为空。
int-id;
智力年龄;
std::字符串名;
矢量测井;
时间;
结构tm*时间结构;
公众:
人();
~Person();
};
#endif//PERSON\u H
\ifndef PERSON\u H
#定义人
#包括
#包括
#包括
#包括“record.h”
班主任
{
私人:
//应在构造函数中指定Person对象创建的id、年龄、姓名和日期。向量“log”在开始时应为空。
int-id;
智力年龄;
std::字符串名;
矢量测井;
时间;
结构tm*时间结构;
公众:
人();
~Person();
};
#endif//PERSON\u H

这对你来说应该可以

你的
记录
课程的收录在哪里?试着在你的源代码中添加
#收录“Record.h”
或类似的东西是的,你需要一个收录指南。亲自添加
#收录“Record.h”
。好的,谢谢,新到C++,不知道你必须把你试图使用的对象的H文件包含在向量中。
#ifndef PERSON_H
#define PERSON_H
#include <string>
#include <vector>
#include <ctime>
#include "record.h"



class Person
{

private:

    //id, age, name, and date of Person object creation shall be assigned in constructor. The vector 'log' shall be empty at start. 
    int id; 
    int age; 
    std::string name; 
    std::vector<Record> log;
    time_t t;
    struct tm * timeStruct;

public:
    Person();
    ~Person();

};

#endif // PERSON_H