开发者

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. My entire header fil开发者_开发问答e 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 ';'

Thank you for any help.


You're missing the namespace:

std::vector


You need to put 'std::' before 'vector' just like you did with string.


In my case, adding the namespace did not work, however, I was missing the

#include <vector>;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜