21
votes

I am having some trouble with vector declarations in the header file of a C++ class I am making. 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 ';'

Thank you for any help.

3
The answer has already been found and the problem was due to programmer negligence. Thanks for the feedback and sorry to post such a silly question on this site. - James W.
Don't you love how useless the compiler error is, after 5 years of C/C++ it's become almost second nature, but after a while using java it just strikes how useless the compiler erro is. - hhafez
I don't think it was silly. I'm pretty new to C++ and I was making the same mistake, so this was just what I needed! - jamesc1101

3 Answers

27
votes

You're missing the namespace:

std::vector
13
votes

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

0
votes

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

#include <vector>;