Jan Maděra Jan Maděra - 1 year ago 88
C++ Question

C++ - Visual Studio - missing type specifier - int assumed

class Space2D {
vector<Agent> v;
bool star;

Space2D() {
bool star = false;

In visual studio this give me a error: missing type specifier - int assumed. I also get errors like syntax error: missing ';' before '<'.

std::vector<Agent> v;
Solved this

Answer Source

Three possible problems with this code.

  1. Possibly vector header is not included

Fix: #include <vector>

  1. Possibly Agent class is not defined

Fix: include header, where Agent class is defined

  1. Possibly you forgot to write using namespace std; as wrongly recommended by beginner books

Fix: instead of 'vector' on line 7 use std::vector, or do it wrong and write using namespace std;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download