Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > unable to pass vector by reference

Reply
Thread Tools

unable to pass vector by reference

 
 
vkaul1 vkaul1 is offline
Junior Member
Join Date: Jun 2009
Posts: 2
 
      06-26-2009
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(100);
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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const vector<A> vs vector<const A> vs const vector<const A> Javier C++ 2 09-04-2007 08:46 PM
Initializing vector<vector<int> > and other vector questions... pmatos C++ 6 04-26-2007 05:39 PM
Free memory allocate by a STL vector, vector of vector, map of vector Allerdyce.John@gmail.com C++ 8 02-18-2006 12:48 AM
Pass by reference / pass by value Jerry Java 20 09-09-2005 06:08 PM
how the vector is created, how to pass vector to webservices method apachesoap:Vector Rushikesh Joshi Perl Misc 0 07-10-2004 01:04 PM



Advertisments