Reputation: 17
Actually am kind of new to c++. i want to display "Questions" if answers is more than one and "Question" if answers in below one these are they errors i get
5 IntelliSense: no operator "<<" matches these operands
operand types are: std::basic_ostream<char, std::char_traits<char>> << std::string c:\Users\Ugwu\Documents\Visual Studio 2012\Projects\Chrysohgomus_Ugwu_A4\Chrysohgomus_Ugwu_A4\mathTutor.cpp 46 39 Chrysohgomus_Ugwu_A4
Or Image Link
This is my code
string Question;
void grade() {
question = correct + incorrect;
if (question > 1){
Question = "Questions";
}
else{
Question = "Question";
}
cout << "Out Of " << question << " " << Question << " You Got " << correct << " Correct " << "And " << incorrect << " Incorrect " << endl;
}
can someone show me the right way?
Upvotes: 1
Views: 614
Reputation: 5059
One possible problem is that either correct or incorrect are not objects that are printable by cout.
It's also possible that you haven't included <string>
correctly in your program. Did you add #include <string>
and using std
in your code?
(Granted, I don't really support the idea of using std
, but if you're going to use string
without the std::
prefix, you have to add using std
. Personally, I think you'd be better off sticking to std::string
.)
Upvotes: 1