Good day everyone, I have a c++ Assignment that says:
Write a program that will have two user defined functions. One function will allow the user to
enter integer values and store them in a vector and return the vector. The other function called
print will accept a vector and output the values stored in it.
I mus confess that I really d not know how to return a vector.
#include <iostream>
#include <vector> // Required Library
usingnamespace std;
storeVector () { // Declaring a vector function
constint size = 5;
vector <int> data; // vector for sotring data of type int
cout << "\tEnter 5 values. Press Enter key after typing a value."; // Initial title
cout << endl << endl;
// Loop for requesti data from user 5 times:
for ( size_t i = 0; i < data.size(); i ++ ) {
cout << "\tEnter any integer value: "; // requesting data from user
data.push_back(i+1);
}
return data; // returning vector
}
int printVector ( vector <int> values ) {
// Display the numbers in the vector:
for ( int i = 0; i < values.values(); i++ ) {
cout << values [i] << " ";
}
}
int main () {
constint size = 10;
vector < int > vec (size, 10); // Test variable / all avlues on teh vector will be 10
storeVector(); // Function Call
printVector(vec); // Function Call
return 0;
}
What I'm suppose to do is to return the vector. Whoever, I get the following errors:
27 9 C:\Users\Qonqueror\Documents\Programming I\Fall 2018\Assignment 1 q 4.cpp [Error] cannot convert 'std::vector<int>' to 'int' in return