In a program the following struct is defined in a header file:
\\structs.h
#include <vector>
using std::vector;
using namespace std;
struct cell
{
double x;
vector<int> nn;
};
In a separate source file I define the function:
\\functions.cpp
# define _CRT_SECURE_NO_DEPRECATE
# include <stdio.h>
# include <iostream>
# include <math.h>
# include <vector>
# include "structs.h"
using namespace std;
void initial_position(vector<cell>& cluster, int n)
{
cell tmp;
for (int i = 0; i < n; i++)
{
tmp.x = 1;
cluster.push_back(tmp);
}
}
with a header file:
//functions.h
# include <vector>
using std::vector;
void initial_position(vector<cell>& cluster, int n);
I wish to call this function in the main script:
//main.cpp
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <vector>
#include "functions.h"
#include "structs.h"
using namespace std;
int main()
{
vector <cell> cluster;
int n = 100;
initial_position(cluster,n);
return 0;
}
but get the following errors:
functions.h(4): error C2065: 'cell': undeclared identifier
functions.h(4): error C2923: 'std::vector': 'cell' is not a valid template type argument for parameter '_Ty'
functions.h(4): error C3203: 'allocator': unspecialized class template can't be used as a template argument for template parameter '_Alloc', expected a real type
main.cpp(14): error C2664: 'void initial_position(std::vector &)': cannot convert argument 1 from 'std::vector>' to 'std::vector &'
What is the source of the errors? it all seems to be well defined.