小编use*_*690的帖子

为什么我不能在C++中重新定义这个变量?

char x;
bool tf;
void IsNumber(char x)
{
    switch (x)
    {
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
        case '0':
            bool tf(true);
            break;
        default:
            bool tf(false);
            break;
    }
}

int main(int argc, const char * argv[])
{
    using namespace std;
    cout << "Test if a character is a number: " << endl;
    char x;
    cin >> x;
    IsNumber((char) x);
    if (bool tf = true)
        cout << "True" << endl; …
Run Code Online (Sandbox Code Playgroud)

c++ variables

-1
推荐指数
1
解决办法
964
查看次数

标签 统计

c++ ×1

variables ×1