`does not name a type` error with `namespace std;` and files
c++, header, namespaces
Solution
Yes but in this example `functions.cpp` has not seen `using namespace std` since you only wrote that in `main.cpp`.
Don't add `using namespace std` to `functions.h`, use `std::` to qualify types. Adding a `using..` imposes an unnecessary burden on the user of your header.
Problem
compiling the code below with `g++ main.cpp functions.cpp -o run` gives me the error `error: ‘vector’ does not name a type`. Declaring namespace at the top of `main.cpp` usually works across all `.cpp` files for me. main.cpp ``` using namespace std; #include "functions.h" main () {} ``` functions.h ``` #include <vector> ``` functions.cpp ``` #include "functions.h" vector <int> x; ``` EDIT: I appreciate the fact all responders know what their talking about, but this normally works for me. Would the use of a makefile have any bearing on that? something else that I might be missing?