Keep_going ; if ( Keep_going == M ) { cout -6ren">
gpt4 book ai didi

C++ 错误 "not declared in scope"编程第二周,

转载 作者:行者123 更新时间:2023-11-28 03:06:51 25 4
gpt4 key购买 nike

这是我编程的第一周,这个项目明天到期。这是代码的重要部分:

char Keep_going;

cout << "What would you like to do? 'M' for menu or 'Q' for quit \n" ;
cin >> Keep_going ;

if ( Keep_going == M )
{
cout << "Returning to menu \n" ;
}

if ( Keep_going == Q )
{
choice = -1;
}


}while ( choice > 0 ) ;

system ("pause");
return 0;

我不断收到错误:

'M' was not declared in this scope

'Q' was not declared in this scope

有人可以帮我解决这个问题吗?

最佳答案

通过简单地使用不带引号的字母 Q 和 M,编译器将它们视为变量。只需用引号将 Q 和 M 括起来就可以解决您的问题。例如“Q”

关于C++ 错误 "not declared in scope"编程第二周,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19460742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com