“vector” was not declared in this scope

You’ve got the declaration in the cpp file and the definition in the header, it should really be the other way round.

After you’ve swapped the files round remove using namespace std; from functia.h as it’s not good practice to pull in namespaces in header files. You’ll need to change the declaration to

void fun(std::vector<double> &, double );

See “using namespace” in c++ headers

I’d also strongly recommend reading C/C++ include file order/best practices

Leave a Comment