#include <vector>
#include <iostream>
#include <string>
//Prototype
getNum(vector<int>);
int main()
{
vector<int> return_values(2); //creates a vector to hold 2 numbers (correct syntax?)
getNum(return_values); //call getNum passing the vector to it.
}
int getNum(vector<int>)
{
//Array
int numbers[3] = {1,7,9}
//How do I now add this array to my vector and return it?
}
The second part is if I had multiple arrays in getNum can i specify how many vectors will be passed to it without writing it like.
int getNum(vector<int>,vector<int>,vector<int>)
Or is that pretty much it? and for the third part! is returning a string vector any different than an integer except changing the syntax from int to a string
#include <vector>
#include <iostream>
#include <string>
//Prototype
getNum(vector<int> *return_values);
int main()
{
vector<int> return_values; //creates a vector to hold numbers
getNum(&return_values); //call getNum passing the vector to it.
}
int getNum(vector<int> *return_values)
{
//Array
int numbers[3] = {1,7,9}
return_values->assign (numbers, numbers+3);
}
For anyone else looking at this code, please post if there is an easier or more effecient way of doing this? seems to be working great at the mo!
How do I pass more than one vector to the function?