Operators like arithmetic, relation, logical works same as works in C. Learn Here .
But CPP also provides some different operators from C.
Following is list of other Operators:
- [::] scope resolution operator.
- [delete] memory release operator.
- [endl] line feed operator.
- [new] memory allocation
- [setw] field width operator
1. Scope resolution operator :
- The notation of scope resolution is :: .
- This operator is used for two purposes:
- This operator tells compiler that the specified function belongs to which class or we can define the definition of member function at outside the class.
Classname ::functionname( )
This operator is used to access the global variable.
2. Memory release operator and 4. Memory allocation :
- Both memory allocation and release operator is known as memory management operator which are used to allocate or deallocate memory occupied by the object.
- For memory allocation ‘new’ is used.
- Syntax :
- ‘new’ keyword can be used to create a memory space for arrays ,classes and structure also.
- For deallocation the memory occupied by new operator delete operator is used.
- Syntax :
3. Line feed operator and 5. Field width operator (setw):
- The line feed and field width operators are known as manupilators.
- The line feed operator (endl) and field width (setw) are used to set the format of displayed data.
- endl is used to insert a new line.