Hey Guys i seem to be having an issue with the follwoing code when i complie in VC++ 2010. It compiles fine in both minGW and VC++ 2008. The code is as follows...
The Program accepts three inputs whereby it outputs them in alphabetical order, very simple.
#include <iostream>
#include <vector>
#include <algorithm>
using std::cout; using std::cin; using std::endl;
using std::string; using std::vector;
int main()
{
string Student_Name;
vector<string>STUDENTS_NAME;
for (int A=0; A<=3; A++)
{
cout<<"Enter a students name: ";
if(cin>>Student_Name)
STUDENTS_NAME.push_back(Student_Name);
sort(STUDENTS_NAME.begin(),STUDENTS_NAME.end());
}
for (int B=0; B<=3; B++)
{
cout << STUDENTS_NAME[B];
cout << endl;
}
return 0;
}
I think the problematic lines are as follows as intellisense tells me "Error: no operator ">>"matches these operands"
if(cin>>Student_Name)
cout << STUDENTS_NAME[B];
When the code is compiled the error is as follows:
error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::istream' (or there is no acceptable conversion)
Any help much appreciated, :)