C++: Small Topics

Operators in C++
  
     <<      insertion operator
     >>      extraction operator
     ::         Scope resolution operator
     ::*      Pointer to member declarator
     ->*     Pointer to member operator
     .*       Pointer to member operator
  delete  Memory release operator
   endl     line feed operator
   new      Memory allocation operator
   setw     Field width operator
__________________________________________

Memory Management Operators

pointer-variable = new data-type;

The new operator allocates sufficient memory to hold a data object of type data-type and returns the address of the object.

pointer-variable = new data-type(value);

pointer-variable = new data-type[size];

delete pointer-variable;

The pointer-variable is the pointer that points to a data object created with new.

delete[size] pointer-variable;

_______________________________________
Manipulators

Manipulators are operators that are used to format the data display.

endl and setw are manipulators.

_______________________________________
Type Cast Operator

type-name (expressioin)

eg.    average=sum/float(i);

_______________________________________
Operator Overloading

Overloading means assigning different meanings to an operation,depending on the context.
Eg. of operator overloading

The operator * when applied to a pointer variable, gives the value pointed to by the pointer.But it is also commonly used for multiplying two numbers.

                      < Happy Coding >

Reference:
OOP by BALAGURUSWAMY

In Association with Amazon.in

Comments

Popular Posts

Top 10 Web Sites Every Programmer Should Visit Daily

What is "namespace" and why do we use it?