The are identifiers that cannot be used as . These are reserved words used as instructions in a C/C++ program.
In this article , we have listed all the common keywords used in C/C++ language with a short description of each.
Keyword | Language | Description |
auto | C/C++ | Auto storage class |
break | C/C++ | Break a loop or block |
case | C/C++ | Part of switch-case |
char | C/C++ | Declares char type |
const | C/C++ | Declares a constant |
continue | C/C++ | Continue a loop |
default | C/C++ | Default switch-case |
do | C/C++ | Do-while loop |
double | C/C++ | Double data type |
else | C/C++ | If-else block |
enum | C/C++ | Enumeration type |
extern | C/C++ | External storage class |
float | C/C++ | Float data type |
for | C/C++ | For loop |
goto | C/C++ | Jump between blocks (Deprecated) |
if | C/C++ | If block |
int | C/C++ | Integer data type |
long | C/C++ | Long data type |
register | C/C++ | Register storage class |
return | C/C++ | Returns a value |
short | C/C++ | Short data type |
signed | C/C++ | Data type with sign |
sizeof | C/C++ | Returns sizeof variable |
static | C/C++ | Static storage class |
struct | C/C++ | Declare a structure |
switch | C/C++ | Switch-Case block |
typedef | C/C++ | User-defined type |
union | C/C++ | Declare a union |
unsigned | C/C++ | Unsigned data type |
void | C/C++ | Void means no type |
volatile | C/C++ | Variables stored in volatile memory |
while | C/C++ | While loop |
The above keywords are common to both C and C++. See the list below for C++ specific keywords. C++ programming has more keywords because it supports object-oriented programming (OOP).
Keyword | Language (C++) | Description |
asm | C++ | gives ability to add assembly language code in C++ program |
catch | C++ | part of try-catch block used for exception handling |
class | C++ | declare a class |
delete | C++ | delete an object |
friend | C++ | declare friend function |
inline | C++ | declare a code or block inline |
new | C++ | create object dynamically with new |
operator | C++ | used to overload C++ operators |
private | C++ | visibility of class member set to private |
protected | C++ | visibility of class member set to protected |
public | C++ | visibility set to public |
template | C++ | declares a template |
this | C++ | reference to current class, where this is used |
throw | C++ | throws a message, result of an exception and it is default or user-defined. |
try | C++ | exception handling using try block |
virtual | C++ | declare a function abstract using virtual, no implementation required for such a function. |
New sets of keyword is added by ASCI C++ which are listed in the following table.
Keyword | Language (ASCI C++) | Description |
bool | C++ | Boolean type with true or false value |
const_cast | C++ | take away the constant-ness of an object. |
dynamic_cast | C++ | cast the type at runtime |
explicit | C++ | used with explicit constructors |
export | C++ | used before template definition in C++ |
false | C++ | Boolean value |
mutable | C++ | storage class |
namespace | C++ | functions, variables, and classes all can come under namespaces. |
reinterpret_cast | C++ | integral type to pointer type conversion and vice-versa |
static_cast | C++ | cast type easily at compile time |
true | C++ | Boolean value |
typeid | C++ | returns a typeinfo object |
typename | C++ | used with C++ template |
using | C++ | tells the namespace the C++ program uses |
wchar_t | C++ | wide character type |