Error: ISO C++ forbids comparison between pointer and integer
#include <iostream>
using namespace std;class Multiplication{
public:
void multiply(){
int a;
int b;
int product;cout << "Enter a number: ";
cin >> a;
cout << "Enter a second number to multiply by " << a << ": ";
cin >> b;product = a * b;
cout << a << "*" << b << "=" << product;
}};
int main()
{
int whatnow;
Multiplication Multiply;
cout << "What would you like to do? \n" " Enter + - * or / : " << endl;
cin >> whatnow;
if(whatnow=="*"){Multiply.multiply();
};
return 0;
}
___________________________________________________________________________
basically im trying to make it so the user can input what they want to do as in multiply, and i keep getting errors here. once i can finish the multiplication part, i can assign it to all others with ease.
int whatnow;
Should bechar whatnow;if(whatnow=="*"){
Should beif(whatnow=='*'){
Thank you so much. now whats the difference between char and int? and how do i know when to use char instead of int?
whats the difference between char and int?
int is an integer. char is a character. If you want to hold a number (for use in, say, multiplication), use int. If you want to hold a character (for, say, general user input), use char.
Also, keep this discussion to one thread. The duplicate has been removed. EDIT: And while we're on the subject, why are you placing each method in an otherwise empty class?
Well im quite new to c++ and I havent learned much about it yet (not even while loops). Also I could use help with that previous problem, it wasnt a duplicate it was a totally different question, because I cannot figure out how to set up the next part for addition. Am I not allowed to use multiple ifs without closing the 1st one?
Different question, but same program. Am I not allowed to use multiple ifs without closing the 1st one?
No, you're allowed to nest ifs.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |