You are on page 1of 16

Introduction to C++

TOPICS TO BE COVERED

• HISTORY OF C++
• CHARACTER SETS
• DATA TYPES
• IDENTIFIERS
• KEYWORDS
• CONSTANT
• VARIABLES
• STRUCTURES OF C++
DISCOVERY OF C++

BJARNE STROUSTRUP AT AT&T BELL LABORATORY IN MUREY HILL NEW JERSEY USA DEVELOPED C++ IN
EARLY 1980S. SINCE 1979 AS AN EXTENSION OF THE C LANGUAGE; HE WANTED AN EFFICIENT AND FLEXIBLE
LANGUAGE SIMILAR TO C THAT ALSO PROVIDED HIGH-LEVEL FEATURES FOR PROGRAM ORGANIZATION
TOKENS:-
THE SMALLEST INDIVIDUAL UNITS OF ANY PROGRAM ARE KNOWN AS TOKENS.

• KEYWORDS
• IDENTIFIERS
• CONSTANTS
• STRINGS
• OPERATORS
Character sets
Every language has some basic elements and grammatical rules before
understanding any programming language it is very useful to learn about the
basic elements of C++ language.
They are :-
1. Alphabets
2. Digits
3. Special Characters
Identifiers
The C++ identifier is a name used to identify a variable, function, class,
module, or any other user-defined item. An identifier starts with a letter A to
Z or a to z or an underscore (_) followed by zero or more letters,
underscores, and digits (0 to 9).
C++ does not allow punctuation characters such as @, $, and % within
identifiers. C++ is a case-sensitive programming language. Thus, Manpower
and manpower are two different identifiers in C++.
RESERVED WORDS/KEYWORDS
Keywords are those words whose meaning is already defined by Compiler. These keywords
cannot be used as an identifier. Note that keywords are the collection of reserved words and
predefined identifiers. Predefined identifiers are identifiers that are defined by the compiler but
can be changed in meaning by the user. 
For example, you could declare a variable called main inside your main function, initialize it,
and then print out its value (but ONLY do that to verify that you can!). On the other hand, you
could not do this with a variable named else. The difference is that else is a reserved word,
while main is "only" a predefined identifier.
asm else new this
auto enum operator throw
bool explicit private true
break export protected try
case extern public typedef
catch false register typeid
char float reinterpret_ca typename
st
class for return union
const friend short unsigned
const_cast goto signed using And bitor not_eq xor
continue if sizeof virtual and_eq compl or xor_eq
default inline static void
bitand not or_eq
delete int static_cast volatile
do long struct wchar_t
double mutable switch while
dynamic_cast namespace template
Datatypes
While writing program in any language, you need to use various variables to
store various information. Variables are nothing but reserved memory
locations to store values. This means that when you create a variable you
reserve some space in memory.
You may like to store information of various data types like character, wide
character, integer, floating point, double floating point, boolean etc. Based
on the data type of a variable, the operating system allocates memory and
decides what can be stored in the reserved memory.
C++ offers the programmer a rich assortment of built-in as well as user defined data types. Following table lists down
seven basic C++ data types −
Several of the basic types can be modified using one or more of these type modifiers −
•signed
•unsigned
•short
•long
Type Keyword
Boolean bool
Character char
Integer int
Floating point float
Double floating point double
Valueless void
Wide character wchar_t
CONSTANT IN C++
• Constants refer to fixed values that the program may not alter and they are called literals.
• Constants can be of any of the basic data types and can be divided into Integer Numerals,
Floating-Point Numerals, Characters, Strings and Boolean Values.
• Again, constants are treated just like regular variables except that their values cannot be
modified after their definition.
VARIABLES:-

A variable provides us with named storage that our programs can manipulate. Each variable
in C++ has a specific type, which determines the size and layout of the variable's memory;
the range of values that can be stored within that memory; and the set of operations that can
be applied to the variable.
STRUCTURE OF C++

You might also like