Operators and their expression in cpp, C/C++ Programming

Operators in C++:

All C operators are valid operators in C++ also.  Besides C++ has developed some new operators like

Operators and their Expression:

1.      Logical operator

2.   Assignment operator: Variable must be declared before assigning. Chain Assignment Ex: x=y=z;

Embedded Assignment Ex: x=(y=10)+10;

Compound or Shorthand Assignment: x = x+y is x +=y; Dynamic initialization Ex: int x=strlen("apple");

Static initialization Ex int x=100;

3.   Reference variable: Ex: int &x=y; x is alias of y.

4.   Relation operator

5. Arithmetic operator

6 Increment and Decrement operator

7 Special operator.

8 Conditional operator.

9 Bitwise operator.

10. Type cast operator: Ex: x =float(a)/float(b).

11. Scope Resolution operator: Ex: :: to access from global variable and class.

12. Insertion and Extraction operator: << and >>.

13. Class Member dereferencing operator:

1 :: To declare pointer to a member in class.

2 ->*  To access pointer member when both class and member have pointers

3 .*     To access pointer member when only member has pointer.

14. Memory  Management  Operator:  new  and  delete.   The  variable  must  be  pointer

variable. In malloc, calloc, realloc, free are used. int *ptr;  ptr = new int;

ptr = new int(25); assigning value delete ptr;  release the memory of ptr.

 

int *ptr; ptr = new int[10];

delete []ptr; release the memory or array pointer.

 

15. Manipulator Ex: endl work like \n and setw(10) set width for the variable cout<<setw(10)<<x<<endl<<setw(10)<<y.

16. Implicit Expression: Conversion is implied from lower to higher order of primary

data type.

17. Operator overloading: Ex: << and >>

Posted Date: 9/20/2012 7:35:53 AM | Location : United States







Related Discussions:- Operators and their expression in cpp, Assignment Help, Ask Question on Operators and their expression in cpp, Get Answer, Expert's Help, Operators and their expression in cpp Discussions

Write discussion on Operators and their expression in cpp
Your posts are moderated
Related Questions
Define Bitwise-AND Operator: &:? The bitwise-AND operator (&) compares every bit of its first operand to the corresponding bit of its second operand. If both bits are 1 the mat


Write a program to create a binary file and store the following data "hello", 0x0030,'1', 1.234  Using visual studio examine the binary file and note how the day is stored   Answe


I have a program for school and I am not understanding why one of the variables gets skipped or the arithmetic operators aren''t having any effect as I have tryed defining it sever

Suppose that three integer variables intA, intB, and intC have already been defined at the beginning of the main function, write a single C++ statement to read three integers from

The digital signal is one which only consists of two states i.e. logic '1'   (+5 volts) and logic '0' (0 volts). Various electronic blocks use logic and these form the basis of a m

Create a .cpp program that verifies the strength of a password that a user is entering is strong (complex/secure) enough. In the main area of the program, prompt the user to enter

Create a program to print a battleship grid to the console and mark squares as destroyed

Problem #1: plugging the memory leak. When you employ the "normal" new operator, for example Foo* p = new Foo(), the compiler generates some special code to manage the case while t