-4

I'm using the standard file, I"m also using the Eclipse IDT. When I use the vector template in my header files, I get "vector does not name a type" error, or I get "Type 'vector ' could not be resolved". I am able to use vector fine in .cpp files in the project. I'm including the header file code below

#ifndef TX_H_
#define TX_H_
#include <vector>

class Tx {
    int nT;
    vector<float> beamform;
public:
    Tx(int);
    virtual ~Tx();
    vector <float> Trans(float);
};

#endif /* TX_H_ */

The line "vector beamform" produces the "vector does not name a type" error. The line vector Trans(float); produces the "Type 'vector ' could not be resolved" error. Please advise. I do need to pass vectors as parameters. So, if I'm not allowed to declare vector types, what is the workaround ?

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • 4
    Use `std::vector` – jrd1 Oct 23 '19 at 17:53
  • 5
    It's `std::vector`, not `vector`. – Yksisarvinen Oct 23 '19 at 17:53
  • 1
    Just a note: *don't* pull the `std` namespace into global via `using` when you fix this. That's neither ideal nor warranted, so don't even consider that. Use proper namespace qualification (`std::vector`) as described above. [Read this discussion](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) to better understand what I'm referring to. – WhozCraig Oct 23 '19 at 17:59

1 Answers1

1

vector does not name a type

You get this error because vector is declared in the std namespace. You need to write std::vector<float> beamform; instead.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268