vectors inside classes

Hi guys,

I'm new here and just beginning to learn C++.

I'm trying to create a vector inside a class and it's giving me lots of errors. For example,

#ifndef DATABASE_H_
#define DATABASE_H_

//#include <vector>

class Database {

public:
Database();
virtual ~Database();

vector<string> firstName;
vector<string> lastName;
vector<string> City;
vector<int> zipCode;
...

and the list goes on.

Please advice. Thanks.

I really hope this isn't your error, but your #include <vector> is commented =P
That would likely do it, although you probably also need to use std::.
Also, you need to #include <string>.

eg,

 
std::vector<std::string> firstName;

Thanks a lot. That indeed work. I didn't include it initially because I have a separate class.cpp and class.h and the #include <vector and #include <string> and using namespace std are all included in the main.cpp

Cheers!
Topic archived. No new replies allowed.