1
class Space2D {
public:
    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

Jan Maděra
  • 521
  • 3
  • 5
  • 17

2 Answers2

1

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;

Starl1ght
  • 4,422
  • 1
  • 21
  • 49
1

Assuming from two error messages you posted and by guessing to which line they correspond to you forget to #include <vector> or you do not have imported std::vector to your namespace (using std::vector; or using namespace std).

I personally would not recommend using either of those usings for reasons and instead wrote std::vector.

Community
  • 1
  • 1
Zereges
  • 5,139
  • 1
  • 25
  • 49