vector arguments

Hello I have 2 questions.

1. I am instructed to make a function with the following declaration;
void Function(std::vector& vec);

Is this a mistake or is it possible to do this without specifying the type:
void Function(std::vector<int> &vec);

2. My main function has the following include directives:
#include <iostream>
#include <cmath>
#include <string>
#include <ctime>
#include <vector>
#include "BasicFunctions.h" 

BasicFunctions.h doesn't contain #include <vector> nor does the corresponding cpp file. This generates the error
BasicFunctions.h(17) : error C2039: 'vector' : is not a member of 'std'

But adding #inlcude <vector> to the .h file fixes the error. This leads me to believe that the .h files are processed and linked before the process enters .cpp. Am I correct in assuming this?

Thank you

1. Yes, it's a mistake; std::vector is a template and needs a type definition when you use it.

2. Almost correct. #include statements are place-holders. During the first pass through your code, the compiler will substitute each #include <header-file> statement with the contents of 'header-file'.

On the next pass through, it compiles the code with those substitutions in place.

Linking only occurs once compilation of each source file is complete.

Thanks Jim.
Topic archived. No new replies allowed.