- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
When is a semicolon after } mandated in C++ Program?
A semicolon after a close brace is mandatory if this is the end of a declaration. In case of braces, they have used in declarations of class, enum, struct, and initialization syntax. At the end of each of these statements, we need to put a semicolon. For example,
class X {}; // same declaration for struct as well enum Y {}; int z[] = {1,2};
A semicolon by itself is an empty statement, and you'll be able to add additional ones anywhere a statement is legal. Therefore it might be legal to place a semicolon right after the braces following your if, although it wouldn't be related to them if at all.
Advertisements