0% found this document useful (0 votes)
3 views

Keywords cpp

Uploaded by

harsh.becse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Keywords cpp

Uploaded by

harsh.becse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

What is a Keyword in C++?

Keywords or reserved words convey a specific meaning to the compiler of C++


programs and it is always written in lower cases. Keywords in C++ language are
generally used for serving some special functions such as void, int, publicand
many more.
Types of keywords in C++
If the question is how many keywords are in C++ then the answer will be, that C++
language has various types of keywords.

C++ Keywords
asm double new switch
auto else operator template
break enum private this
case extern protected throw
catch float public try
char for register typedef
class friend return union
const goto short unsigned
continue if signed virtual
default inline sizeof void
delete int static volatile
do long struct while

Explanation of Keywords in C++


1. Asm: It is used to declare a block of code that has to be passed to the
assembler.
2. auto: This keyword is a storage class specifier that is used for defining
objects in a particular block.
3. break: This statement terminates any switch statement or any loop.
4. case: This keyword is used specifically within a switch statement to specify
a match for the expression of the statement.
5. catch: It specifies which actions have to be taken when an exception occurs.
6. char: This is one of the fundamental data types in C++ language that defines
character objects.
7. class: It is used to declare a user-defined data type that encapsulates any
data members and operations or member functions of a particular class.
8. const: This keyword helps to define objects whose value will not alter
throughout the lifetime of execution of that particular program.
9. continue: It transfers control to the starting point of a loop.
10.default: This keyword handles expression values in a switch statement that
could not be handled by case.
11.delete: It is a memory deallocation operator.
12.do: indicate the start of a do-while statement in which the sub-statement is
executed repeatedly until the value of the expression is logical-false.
13.double: Fundamental data type used to define a floating-point number.
14.else: Used specifically in an if-else statement.
15.enum: To declare a user-defined enumeration data type.
16.extern: An identifier specified as an extern has an external linkage to the
block.
17.float: Fundamental data type used to define a floating-point number.
18.for: Indicates the start of a statement to achieve repetitive control.
19.friend: A class or operation whose implementation can access the private
data members of a class.
20.long: A data type modifier that defines a 32-bit int or an extended double.
21.new: Memory allocation operator.
22.operator: Overloads a C++ operator with a new declaration.
23.private: Declares class members who are not visible outside the class.
24.protected: Declares class members who are private except to derived
classes
25.public: Declares class members who are visible outside the class.
26.register:A storage class specifier that is an auto specifier, but which also
indicates to the compiler that an object will be frequently used and should
therefore be kept in a register.
27.goto: This keyword helps to transfer the power of the control to a specified
label.
28.if: It indicates the starting point of an if statement to achieve selective
control.
29.inline: A function specifier that indicates to the compiler that inline
substitution of the function body is to be preferred to the usual function
call implementation.
30.int: fundamental data type used to define integer objects.
31.return: Returns an object to a function’s caller.
32.short: A data type modifier that defines a 16-bit int number.
33.signed: A data type modifier that indicates an object’s sign is to be stored in
the high-order bit.
34.sizeof: Returns the size of an object in bytes.
35.static: The lifetime of an object-defined static exists throughout the lifetime
of program execution.
36.struct: To declare new types that encapsulate both data and member
functions.
37.switch: This keyword is used in the switch statement.
38.template: parameterized or generic type.
39.this: A class pointer points to an object or instance of the class.
40.throw: Generate an exception.
41.try: Indicates the start of a block of exception handlers.
42.typedef: Synonym for another integral or user-defined type.
43.union: Similar to a structure, struct, in that it can hold different types of
data, but a union can hold only one of its members at a given time.
44.unsigned: A data type modifier that indicates the high-order bit is to be
used for an object.
45.virtual: A function specifier that declares a member function of a class that
will be redefined by a derived class.
46.void: This keyword identifies the absence of a type or function parameter
list.
47.volatile: This particular keyword defines an object that may vary in value in
a way that is undetectable to the compiler.
48.while: This keyword helps to start a while statement and end a
do...whileloop.

You might also like