Hey all, I've been writing a program for a week. I have a class with private string vectors and a few public set and get functions to set and call them up. This program is going to read a file and store the info in the different vectors in the class. Also if its any consolation it's written in three parts; header, cpp, and main.
This is where it gets tricky (at least for me)
I haven't a clue how to set up a function that calls the vector from main and has a int parameter to call a specific spot within the vector.
Can you clarify; this is a vector of strings, yes?
If so, a function like this would do in your class.
1 2 3 4 5 6 7 8 9
// Assuming vector object called myVector in class
std::string GetStringAtIndex( unsignedint idx )
return idx < myVector.size() ? myVector[idx] : " ";
// Example call
// Assuming you have an instance of your class
std::string someString = yourObject.GetStringAtIndex( 0 );