
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
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.
- Related Articles
- When should I use a semicolon after curly braces in JavaScript?
- What does a semicolon do after a C++ class name?
- Why should we use a semicolon after every function in JavaScript?
- Do I need to use a semicolon after every function in JavaScript?
- How to print a semicolon(;) without using semicolon in C/C++?
- C Program to print “Hello World!” without using a semicolon
- Write a program to print ‘Tutorials Point’ without using a semicolon in C
- What will happen if a semicolon is misplaced in JavaScript?
- Write a C program to print “ Tutorials Point ” without using a semicolon
- Maximums from array when the maximum decrements after every access in C++ Program
- Semicolon Conventions in Lua Programming
- Golang Program to update the node value after the Kth node (When K is not in the linked list).
- What is a method in Java that ends in a semicolon and has no method body?
- A balloon when kept in sun, bursts after some time. Why?
- C Program to print numbers from 1 to N without using semicolon

Advertisements