Hey again.Each new program I try to create brings about new errors I don't know how to deal with. Can someone explain to me what I'm doing wrong here? It' telling me that I need to have my expressions be integral or enum type, but I was never explained any of that in class. Any help is appreciated. The error appears in the if/else statements.
#include <iostream>
#include <string>
using namespace std;
cout << "Enter three numbers and I will tell you which number is the median." << endl;
cout << "Enter the first number." << endl;
cin >> num1 ;
cout << "Enter the second number." << endl;
cin >> num2 ;
cout << "Enter the third number." << endl;
cin >> num3 ;
By default:
> is a comparison operator. It checks whether one value is greater than the other and returns a boolean value.
>> is a binary shift operator. It shifts around bits on a binary level, by default. cout and cin have overloaded these to mean different thing, but by default it's a binary shift operator, and that must have an integer or enum type as a parameter.
My if/else statements are exactly how the instructor told us to write them. And he never explained the differences in the main() headings or even said how many there were.
This class is making me hate programming altogether. I can't complete anything without assistance from someone else because I don't feel like I'm learning anything in class. I'm sorry that I'm being such a burden on the forums here.
Thank you for your help with the problem. I did what you said, and it works just fine. I have ten weeks left of this, and then I don't have to worry about programming any longer.
If your teacher seriously said in class that >> was by default a greater than comparison operator in C++ and you were not hallucinating then I swear I'll... wait a sec... where's my chainsaw and bondage kit? :P
Jokes aside, I recommend that you read up from the tutorial here (go in order and start from the beginning. This tutorial is a really good one): http://cplusplus.com/doc/tutorial/
I didn't hallucinate. Trust me. My instructor writes the start of the code on the board in class, and we copy it down. Since he wrote if(num1 >> num2 && num1 << num3) on the board, I copied it exactly.
Thank you for the tutorials. I will definitely use them.