I was wondering why both versions of this code have no error:
#include <iostream>
bool check_number(int n) {
return n < 5;
}
int main() {
int number = 6;
// (1) prints "Hello World"
if (check_number)
// (2) prints "not hello world"
if (check_number(number))
{
std::cout << "Hello world!";
}
else
{
std::cout << "not hello world";
}
return 0;
}
Condition (1) prints Hello world!
despite the fact that I have not passed the variable number
into the function check_number
in the if-statement.
In case (2), I get not hello world
as expected.