I am quite new to C++, coming from an interpreted language I am having a bit of difficulty with understanding how header files relate to libraries and dependencies.
For example, suppose I have the main body of my project:
#include <vector>
//----------------------------define some auxiliary function which deals with vectors
void A(std::vector<int> &vect)
{
vect.clear();
}
//----------------------------main body
int main()
{
std::vector<int> vect = {1,2,3}
A(vect);
return 0 ;
}
Now suppose I want to define the auxiliary function A() in a separate .cpp file, and still be able to call it from my main .cpp file. My question is- for this project, do I have to #include <vector> in all .cpp files which use something from that library? If so, do I still need to #include <vector> in my main file?
I think I understand how header files work, but it is still unclear what happens if I have several files using elements from the same library.