well I have some questions that have to do with some basic c++, but I cannot figure it out by myself so here I am.Code:#include<iostream>
#include<vector>
#include<string>
using namespace std;
void builtVector(string vectorName);
//void sortVector(string vectorName);
int main()
{
builtVector("v");
//sortVector(v);
for(int i = 0; i <= v.size(); i++)
{
cout << v[i];
}
return 0;
}
vector<int> builtVector(final string vectorName)
{
vector<int> vectorName;
vectorName.push_back(4);
vectorName.push_back(2);
vectorName.push_back(7);
vectorName.push_back(1);
return vectorName;
}
--------------------Configuration: mingw2.95 - CUI Release, Builder Type: MinGW (Old)--------------------
Compiling C:\Program Files\C-Free 4\temp\Untitled3.cpp...
[Error] C:\Program Files\C-Free 4\temp\Untitled3.cpp:14: `v' undeclared (first use this function)
[Error] C:\Program Files\C-Free 4\temp\Untitled3.cpp:14: (Each undeclared identifier is reported only once
[Error] C:\Program Files\C-Free 4\temp\Untitled3.cpp:14: for each function it appears in.)
[Error] C:\Program Files\C-Free 4\temp\Untitled3.cpp:21: parse error before `vectorName'
Complete Compile C:\Program Files\C-Free 4\temp\Untitled3.cpp: 4 error(s), 0 warning(s)
I use builtVector to initialize a vector, with param string vectorName; so when I call builtVector("v"); a vector v should be initialized. Anyway I get the above errors.
Also if I have to return a vector should the return type of my fuction be vector or vector<int>???