if语句
if简单使用
#include<iostream>
int main()
{
int x = 5;
bool comparisonResule = x == 5;
if (comparisonResule == true)
{
std::cout << "hello" << std::endl;
}
std::cin.get();
}
if和else if
#include<iostream>
int main()
{
const char* ptr = "Hello";
if (ptr)
std::cout << "Hello" << std::endl;
//只有if语句不可行才会启动else if
else if(ptr == "Hello")
std::cout << "Ptr is Hello" << std::endl;
else
std::cout << "Null" << std::endl;
std::cin.get();
}