对象创建错误的C++矢量
C++ vector of object creation error
我试图给程序中的每个"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_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
这应该为你做
相关文章:
- 分段故障(堆芯转储)矢量
- 为什么在popback()操作之后,它仍然打印完整的矢量
- 将二维矢量传递给类
- 读取文件并输入到矢量中
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 无法通过空白将文本文件行分隔为矢量
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- 正在将csv文件读取为双精度矢量
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 如何通过 getter 函数删除矢量的元素?
- 如何在C++中将数组转换为矢量指针
- 在C++中将矢量转换为嵌套地图
- C++矢量迭代
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 将矢量<T>转换为矢量<数组<T>>
- 指针或结构的矢量
- 为什么文件名被设置为一个点,而不是在读取矢量中的文件名时
- 用于矢量处理的多个线程
- 反向矢量3
- cmath抛出错误C2062、C2059、C2143和C2447.cmath包含在矢量文件中