"else" DevC++ 之前的预期主表达式
Expected primary expression before "else" DevC++
我得到错误"预期的主表达式之前"else"在这部分代码。然而,我找不到解决办法。如有任何帮助,我将不胜感激。
//create class Date object today
Date today (monthT, dayT, yearT);
// check today date that it is correct
if(!(today.checkDate(monthT, dayT, yearT)))
cout << "Today's date is wrong!" << endl;
return 0;
else
//increment date to get tomorrow
cout << "Tomorrow is " << monthT << ", " << dayT+1 << ", " << yearT << "." << endl;
您错过了大括号:
//create class Date object today
Date today (monthT, dayT, yearT);
// check today date that it is correct
if(!(today.checkDate(monthT, dayT, yearT))) { //<---
cout << "Today's date is wrong!" << endl;
return 0;
} else //<---
//increment date to get tomorrow
cout << "Tomorrow is " << monthT << ", " << dayT+1 << ", " << yearT << "." << endl;
相关文章:
- (C++)分析树以计算返回错误值的简单算术表达式
- 在VS2010-VS2015下编译时,如何使用decltype作为较大类型表达式的LHS
- 提升精神:解析布尔表达式并简化为规范范式
- 我的简单if-else语句是如何无法访问的代码
- 不能在初始值设定项列表中将非常量表达式从类型 'int' 缩小到'unsigned long long'
- 线程,如果else语句,都是错误的上下文切换后,会发生什么
- 使用正则表达式regex_search在字符串中查找字符串
- 如何确认我的constexpr表达式实际上已经在编译时执行
- 概念中的cv限定符需要表达式参数列表
- 为什么constexpr的性能比正常表达式差
- 对于结构,表达式必须是可修改的ivalue
- 如何删除peer if else分支中的冗长句子
- 我似乎对if/else的基本语句有问题:/
- 当一个值是非常量但用常量表达式初始化时使用constexpr
- 为什么我不能在我的三元表达式中使用 return,但我可以在常规的 if-else 语句中使用?
- IF-ELSE语句的Lambda表达式的返回类型扣除
- 错误"else"之前的预期主表达式
- 在令牌和'else'之前'%'预期的主表达式,没有以前的'if'
- "else" DevC++ 之前的预期主表达式
- 这个三元表达式的等价if else语句是什么?