passing vector by reference huge problems

Joined
Jun 26, 2009
Messages
1
Reaction score
0
I am not able to pass vector by reference if I read it from a txt file and populate it. What is wrong with the code here

#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>


void signedDistanceTransform2D(vector<int> &iContour);
using namespace std;

int main()
{
fstream infile("crack_index.txt");
vector<int> iContour;
if(!infile)
{ cout<<"Error opening output file"<<endl;
system("pause");
return -1;
}
else
{ int C_point=0;
// checking for the current point
while(infile>> C_point)
{
//putting the initial crack points in the vector
iContour.push_back(C_point);



}


signedDistanceTransform2D(iContour);

return 0;
}
}


void signedDistanceTransform2D(vector<int> &iContour) {}



It is throwing errors like which is bizarre

\Users\vivek\Documents\main.cpp(7) : error C2065: 'vector' : undeclared identifier
C:\Users\vivek\Documents\main.cpp(7) : error C2062: type 'int' unexpected
C:\Users\vivek\Documents\main.cpp(13) : error C2872: 'vector' : ambiguous symbol
C:\Users\vivek\Documents\main.cpp(13) : error C2872: 'vector' : ambiguous symbol
C:\Users\vivek\Documents\main.cpp(13) : error C2062: type 'int' unexpected
C:\Users\vivek\Documents\main.cpp(25) : error C2065: 'iContour' : undeclared identifier
C:\Users\vivek\Documents\main.cpp(25) : error C2228: left of '.push_back' must have class/struct/union type
C:\Users\vivek\Documents\main.cpp(32) : error C2065: 'signedDistanceTransform2D' : undeclared identifier
C:\Users\vivek\Documents\main.cpp(43) : error C2872: 'vector' : ambiguous symbol
C:\Users\vivek\Documents\main.cpp(43) : error C2872: 'vector' : ambiguous symbol
C:\Users\vivek\Documents\main.cpp(43) : error C2062: type 'int' unexpected
C:\Users\vivek\Documents\main.cpp(43) : error C2143: syntax error : missing ';' before '{'
C:\Users\vivek\Documents\main.cpp(43) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.

main.obj - 13 error(s), 0 warning(s)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top