Hi,
I am a beginner of c++ as you see this post in beginner section :). Iam having troubles with running small programs created as practice. In this program, I am trying to get inputs from a function and add to the vector and print the vector.
FYI: I am using codeblocks compiler.
int main()
{
vector <int> *_vote;
for(i=0;i<=10;i++)
{
int choice = choose();
_vote = new vector <int>();
_vote->push_back(choice);
}
cout<< _vote->size()<<endl;
_getch();
}
int choose (int x)
{
int x;
cout<< "Enter your choice, 1,2 or 3: ";
cin>>x;
return x;
}
The error displayed:
\Vect_pract02.cpp: In function 'int main()':
\Vect_pract02.cpp:12:9: error: 'i' was not declared in this scope
\Vect_pract02.cpp:14:29: error: too few arguments to function 'int choose(int)'
\Vect_pract02.cpp:7:5: note: declared here
\Vect_pract02.cpp: In function 'int choose(int)':
\Vect_pract02.cpp:24:8: error: declaration of 'int x' shadows a parameter
Cubbi
Thanks for the reply, but i have tried like how you did initially. And had tried the same way again now.. not working, and throwing the same error. Will it be because i am using code blocks rather than visual c++ ?