Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
continue
是 C++ 中的关键字,因此不能拥有具有该名称的变量。continue
is a keyword in C++, so you cannot have a variable with that name.您应该将代码放在 while 循环中。
You should put your code in a a while loop.
除了
continue
是保留字之外,在C++中调用main
也是非法的。来自 '03 标准,§3.6.1/3:In addition to
continue
being a reserved word, it is illegal to callmain
in C++. From the '03 standard, §3.6.1/3:continue 用于短路循环,例如:
continue is used to short-circuit loops, e.g.:
continue 是一个 C++ 关键字,请使用不同的名称
而不是
try
continue is a c++ keyword, use a different name for it
instead of
try
我的 2 美分:扔掉所有这些东西,并重写它,记住
goto
和标签是不好的;do
...while
);main
中递归是不好的(实际上,根据标准这是非法的);#include
是不可选的。也许将用户输入/验证逻辑移到单独的函数中以避免代码重复。
My 2¢: throw away all this stuff, and rewrite it keeping in mind that
goto
s and labels are bad;do
...while
in your case);main
is bad (actually, it's illegal according to the standard);#include
s are not optional.And maybe move the user input/validation logic in a separate function to avoid code duplication.