I'm trying to figure out how I can return a vector from a method
so that I can print the results in main().
Example:
When I do this I get a compiler error until I copyCode:class test{ public: vector <string> A(vector <string> a, vector <string> b){ vector <string> retval; retval.push_back("test"); return (retval); } }; // int main(void){ test p; p.A; cout<<A[0]; }
into the main function. However, this reinitializes the retval vector. How, can I code this so that I don't have to reinitialize the vector in main?Code:vector <string> retval;
Thanks in advance.