小编jud*_*omi的帖子

带有if语句的C++字符串变量

我已经尝试以各种可能的方式重新定义这些变量,以尝试让这条线工作.我将在这里举一个例子来表示令我不安的问题.

double const FRAME_COST = 45.00;
string input;
char yes,
     no;
int frames;


cout << "Do you want additional frames? Type yes/no:  ";
cin  >> input;

    if (input == yes){
       cout << "How many?"
       cin >> frames;
       frames = frames * FRAME_COST;
       }

// The problem is in **the if statement**
// I need to use a string not a bool (according to my professor)
// I can't get the compiler to recognize the **if statement**
// I realize this …
Run Code Online (Sandbox Code Playgroud)

c++ string if-statement

1
推荐指数
1
解决办法
6万
查看次数

标签 统计

c++ ×1

if-statement ×1

string ×1