Search

C++ IN DEPTH

HISTRY OF C++ :

               history :

  •  C++ was invented by Bjarne Stroustrup in 1979 , at Bell laboratories in murray hill , New Jersey. He initially called new language "C with classes" . in 1983 the name was changed to C++ . 

  • instead, he enhanced an already highly successful language . most of the features that stroustrup added to c were designed to support object-oriented programing . in essence , C++ is object-oriented version of c. 

   

feature : 
  1. middle level language .
  2. it support object-oriented programing.
  3. C++ follow bottom up approch.
  4. java is written in C++

KEYWORDS :

 Every words in C++ language is a keyword or an identifier . Keywords in C++ language can not be used as a variable name . They are specifically used by the compiler for its own purpose and they serve as   building blocks of a C++ program.

 C++ language has some reserve word which are called keywords. They are the part of the C++ tokens.

There are 63 keywords currently defined for standard C++. 


C++ Keyword

asmdoublenewswitch
autoelseoperatortemplate
breakenumprivatethis
caseexternprotectedthrow
catchfloatpublictry
charforregistertypedef
classfriendreturnunion
constgotoshortunsigned
continueifsignedvirtual
defaultinlinesizeofvoid
deleteintstaticvolatile 
dolongstruct
while 



IDENTIFIER : 


         the name of a variable , function , class , or other entity in c++ is called an identifier.

rules :  

  •  The identifier can not be a keyword . Keywords are reserved .
  • The identifier can only be composed letters, number , and the underscore character . that means the name can not contains symbols nor whitespace .
  • The identifier must begin with a letter or an underscore . it can not start with a number ,
  • C++ distinguishes between lower and upper case letter . 

VARIABLE: A variable is a value that can change anytime . It is a memory location used to store a data value . variable name is case sensitive.

  1. They must always begin with a letter , although some system permit underscore as the first character.
  2. The length of a variable most not be more than 8 character.
  3. white space is not allowed .
  4. a variable should not be a keyword.
  5. it should not contain any special characters.

example of invalid variable names are :
 
123 , (area) , -hello , %abc , etc.

A variable must be declared before it can be used . Variables can be declared at the start of any block of code .


 "Data types specifies the type and size of data . "

A program contains different types of data (integer , real , character etc.)  and need to store values being used in the program . C++ language is rich of data types . 

It is divided into three types ------------------

  1. Primary data types 
  2. Derived data types 
  3. User Defined data types

Data Type

Size (in bytes)

Range

short int

2

-32,768 to 32,767

unsigned short int

2

0 to 65,535

unsigned int

4

0 to 4,294,967,295

int

4

-2,147,483,648 to 2,147,483,647

long int

4

-2,147,483,648 to 2,147,483,647

unsigned long int

4

0 to 4,294,967,295

long long int

8

-(2^63) to (2^63)-1

unsigned long long int

8

0 to 18,446,744,073,709,551,615

signed char

1

-128 to 127

unsigned char

1

0 to 255

float

4

 

double

8

 

long double

12

 

wchar_t

2 or 4

1 wide character


No comments:

Post a Comment

DATA TYPES

 "Data types specifies the type and size of data . " A program contains different types of data (integer , real , character etc.) ...