在";"之前应出错
error expected `;' before
本文关键字:出错 更新时间:2023-10-16
我似乎不明白为什么它一直在说期望的`;'在第28行"keep_window_open"之前,请帮助
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
inline void keep_window_open(){char ch;cin>>ch;}
int main()
{
cout<<"Please enter your first name(followed by 'enter'):n";
string first_name;
cin>>first_name;
cout<<"hello,"<<first_name<<"!n";
keep_window_open();
return 0;
cout<<"please enter last name:n";
string Last_name;
cin>> Last_name;
cout<<"hello,"<<first_name<<Last_name<<"!n"
// this is the only keep_window_open() function that gives me the problem
keep_window_open();
return 0;
}
在c++中,您的语句应该以;
结尾
cout<<"hello,"<<first_name<<Last_name<<"!n"
语句应以;
结尾
cout<<"hello,"<<first_name<<Last_name<<"!n";
以下是需要终止的语句列表
Statement type Termination required?
============== =====================
labelled statement N (a)
expression Y
compound statements N (a)
selection statements N (a)
iteration statements N (a) (b)
jump statements Y
declaration statement Y
(a) 尽管有时可能会出现以分号结尾的情况,但事实并非如此。声明:
if(i==1)doSomething();使用分号终止内部表达式语句,而不是复合语句,当您检查上面的第一个包含在{}大括号中的代码段时,这一点应该很明显。
(b) do需要while表达式后面的分号。
因为您之前忘记了行上的;
(cout
,末尾没有;
):
更改:
cout<<"hello,"<<first_name<<Last_name<<"!n"
至:
cout<<"hello,"<<first_name<<Last_name<<"!n";
看看情况是否没有好转。
相关文章:
- 访问者访问变体并返回不同类型时出错
- 在Linux for Windows上编译C++代码时出错
- 读取文件的最后一行并输入到链接列表时出错
- 重载操作程序时出错>>用于类中的字符串 memebr
- 调用专用模板时出错"no matching function for call to [...]"
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- LINK 尝试使用 OpenSSL evp aes 256 c++ 时出错
- 在Google Kick start中提交时出错
- 在c++中访问int到类对象的映射时出错
- 分段错误当我试图运行程序时出错
- 使用dynamic_cast和构造函数时出错
- CHECK(调用)函数在Google Colab中出错
- 用pybind11包装C++抽象类时出错
- 为x86而非x64编译时出错
- 从R调用C++函数并对其进行集成时出错
- 这个函数哪里出错了
- C++ 创建包含链表和字符串的对象的链接列表时出错
- 为重写std::exception的库生成swig接口时出错
- 导入/导出变量时出错
- PrintWindow函数在notepad.exe中出错