'vector' was not declared in this scope

Linux GCC says that in line 10 there's the error: 'vector' was not declared in this scope. An extract of the source code is the following (after having included <vector> header):

typedef struct {

float etx, pf, pr;
struct in_addr addr;

}neigh;

std::vector<neigh>neigh_list; (here is line 10)

Please somebody help me!!!!

This might be a stupid question but when you say gcc do you mean you compile using gcc or g++ in the terminal?
The code below compiles without error.

If I had to guess, I'd say that you didn't include <vector>, even though you say you have.

Also, you cannot use in a template argument an object where that object has local scope. You will have to move your definition of the neigh struct. Also, this is C++; not C. You don't need to create your structs with that clumsy typedef anymore and when you create an instance of a struct, do not do it like this:

struct in_addr addr;

but like this

in_addr addr;


1
2
3
4
5
6
7
8
9
10
11
12
13
#include<vector>
struct neigh { 
float etx, pf, pr; 
};

int main()
{



std::vector<neigh> neigh_list;
 return 0;
}
Last edited on
Topic archived. No new replies allowed.