I'm watching a Youtube guide about "if statements" and wanted to experiment a little but by adding a third outcome that the numbers are equal but I keep getting thrown this error:
No suitable conversion function from "std::string to "int" exists
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int getMax(int num1, int num2){
int result;
string areEqual("The numbers are equal");
if (num1 > num2) {
result = num1;
}
else if (num1 < num2) {
result = num2;
}
else (num1 == num2); {
* return string(areEqual);
}
return result;
}
int main(){
cout << getMax(5, 5);
return 0;
}
This is what I currently have, I tried looking into the std::stoi function but the resource I found on cppreference.com was pretty confusing to me.
Visual studio also seems to think there is an error on line 20 claiming that there is a missing semicolon, Not sure why though ( I highlighted the line with a *)
apologies if any of this is worded poorly or completely incorrect, I've only just started with c++ yesterday.