简体   繁体   English

“其他” DevC ++之前的预期主表达式

[英]Expected primary expression before “else” DevC++

I am getting the error "expected primary-expression before "else"" in this portion of the code. 我在此部分代码中收到错误“在“其他”之前预期的主要表达式”。 I however cannot find a solution. 但是,我找不到解决方案。 Any help would be greatly appreciated. 任何帮助将不胜感激。

//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; 

You missed the braces: 您错过了花括号:

//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; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM