Add to Technorati Favorites
Google

Keywords in C++

In the last post, we saw the anatomy of a C++ program. Now before writing a simple C++ program, it is important to familiarize us with keywords in C++.
The language that we speak or write consists of sentences which in turn comprises of different parts of grammar, for example, nouns, verbs, adjectives, prepositions, articles, punctuations, and so on. Similarly, C++ program consists of statements which in turn comprises of keywords, variables, constants, strings constants, operators, punctuators, escape sequences etc.
Today, we will know what are keywords and which keywords are available in C++.
Keywords are explicitly reserved identifiers that have strict meaning. These keywords cannot be redefined/used in other contexts. Some of these keywords may be specific to compiler implementation like near and far are available in Borland C++.
There are about 62 keywords which are listed below:
asm
insert an assembly instruction
auto
declare a local variable
bool
declare a boolean variable
break
break out of a loop
case
a block of code in a switch statement
catch
handles exceptions from throw
char
declare a character variable
class
declare a class
const
declare immutable data or functions that do not change data
const_cast
cast from const variables
continue
bypass iterations of a loop
default
default handler in a case statement
delete
make memory available
do
looping construct
double
declare a double precision floating-point variable
dynamic_cast
perform runtime casts
else
alternate case for an if statement
enum
create enumeration types
explicit
only use constructors when they exactly match
export
allows template definitions to be separated from their declarations
extern
tell the compiler about variables defined elsewhere
false
the boolean value of false
float
declare a floating-point variable
for
looping construct
friend
grant non-member function access to private data
goto
jump to a different part of the program
if
execute code based off of the result of a test
inline
optimize calls to short functions
int
declare a integer variable
long
declare a long integer variable
mutable
override a const variable
namespace
partition the global namespace by defining a scope
new
allocate dynamic memory for a new variable
operator
create overloaded operator functions
private
declare private members of a class
protected
declare protected members of a class
public
declare public members of a class
register
request that a variable be optimized for speed
reinterpret_cast
change the type of a variable
return
return from a function
short
declare a short integer variable
signed
modify variable type declarations
sizeof
return the size of a variable or type
static
create permanent storage for a variable
static_cast
perform a nonpolymorphic cast
struct
define a new structure
switch
execute code based off of different possible values for a variable
template
create generic functions
this
a pointer to the current object
throw
throws an exception
true
the boolean value of true
try
execute code that can throw an exception
typedef
create a new type name from an existing type
typeid
describes an object
typename
declare a class or undefined type
union
a structure that assigns multiple variables to the same memory location
unsigned
declare an unsigned integer variable
using
import complete or partial namespaces into the current scope
virtual
create a function that can be overridden by a derived class
void
declare functions or data with no associated data type
volatile
warn the compiler about variables that can be modified unexpectedly
wchar_t
declare a wide-character variable
while
looping construct
These keywords I have posted here from:
http://www.cppreference.com/keywords/index.html
Tommarrow, we will learn about identifiers, constants, string constants, operators, and rules concerning them

No comments: