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)
#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)