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, :)

Clearly Visual C++ 2010 is smarter in terms of implicit standard headers. You failed to include <string>, and the compiler rightly complains. The others don't complain because <string> is probably included inside one of the other three standard headers you've included, so the bug goes unnoticed.

How did i not see that, thank-you very much Narue :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.