void DisplayVector( vector<string> args ) { cout << args[0] << "\t" << args[1] << endl; } void DisplayAllVectors( vector<vector<string>> args ) { for each (vector<string> vect in args) { DisplayVector(vect); } }
That code seems to work well, but there is a semantic error in it somewhere. I don't know why, but when I run the code it seems to simply cycle through the master vector... It's easier to see what I mean when it runs.. I have attached the source code to the entire program, but the problem definitely lies somewhere in those two functions.
I have attempted to erase vect (args) after I am done with it in DisplayVect, but that ends up with a nasty error. Logically, I shouldn't have to erase it at all since it should move on to the next one in DisplayAllVectors, but whoever said computers are logical...harhar
Vermiculus, on 25 Nov, 2009 - 01:23 PM, said:
I have attached the source code to the entire program, but the problem definitely lies somewhere in those two functions.
For some reason it did not attached, so I am trying again... hopefully it'll work...

By the way, it is possible to jerryrig the error and make it work by replacing it with the following
int derp = 0; void DisplayVector( vector<string> args ) { cout << args[derp] << "\t" << args[derp+1] << endl; derp++; } void DisplayAllVectors( vector<vector<string>> args ) { for each (vector<string> vect in args) { DisplayVector(vect); } }
But it's still confusing me why this error would occur in the first place.
Attached File(s)
-
Program.txt (3.55K)
Number of downloads: 92
This post has been edited by Vermiculus: 25 November 2009 - 02:32 PM