[英]Declaring vectors in a C++ header file
I am having some trouble with vector declarations in the header file of a C++ class I am making. 我在我正在制作的C ++类的头文件中使用向量声明时遇到了一些麻烦。 My entire header file looks like this:
我的整个头文件如下所示:
#ifndef PERSON_H
#define PERSON_H
#include "Message.h"
#include <string>
#include <vector>
class Person {
public:
Person() {};
Person(std::string emailAddress);
private:
vector<Message> inbox;
vector<std::string> contacts;
std::string emailAddress;
};
#endif PERSON_H
My error occurs on the lines following the "private" declaration (where I declare my vectors). 我的错误发生在“私有”声明(我声明我的向量)之后的行上。 The error I am getting is C4430 - missing type specifier and and C2238 - unexpected tokens preceding ';'
我得到的错误是C4430 - 缺少类型说明符和C2238 - ';'之前的意外标记
Thank you for any help. 感谢您的任何帮助。
你错过了命名空间:
std::vector
你需要把'std ::'放在'vector'之前,就像你对string一样。
在我的情况下,添加命名空间不起作用,但是,我错过了
#include <vector>;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.