if you replace else if with just if then it prints correct part of the code and else statement |
Hi, @xxvms
as far as I can see it’s what it should do, it’s not?
If you enter let's say “three”, then:
is it “zero”? --> no, let’s go on
is it “one”? --> no, let’s go on
is it “two”? --> no, let’s go on
is it “three”? --> yes! Let’s print “Number entered is 3”
is it “four”? --> no, let’s execute the “else” statement:
print out: “I am sorry I don't recognise...”
Did I misunderstood your question?
BTW:
std::string number = " ";
strings are objects, so they’re initialized in the constructor as empty strings when they are not assigned a value. I mean, they start in a consistent state anyway.