| | |
Definitions Some C++ operators
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Hello all. I have been reading / practising c++ and through the course of my journey I have been encountering some phrases that I don't understand. The phrases are :
-> Binary operators
-> Unary operators
I have tried to search on google and also on other posts in the forum but I just keep finding them used but I don't understand what exactly they do. I am simply looking for a definition of these terms. Your help will be appreciated.
Thank You.
-> Binary operators
-> Unary operators
I have tried to search on google and also on other posts in the forum but I just keep finding them used but I don't understand what exactly they do. I am simply looking for a definition of these terms. Your help will be appreciated.
Thank You.
A binary operator is an operator like + or / that have two operands, one on each side. A unary operator is an operator that only has one operand:
C++ Syntax (Toggle Plain Text)
a * b // binary true && false // binary -1 // unary !x // unary
-Tommy (For Great Justice!) Gunn
•
•
Join Date: Jan 2008
Posts: 57
Reputation:
Solved Threads: 5
Hi,
Binary means having two operands for doing the operation
while unary have only one operand to do any operation.
suppose you have the following code for binary operation
while in the case of unary operator
Binary means having two operands for doing the operation
while unary have only one operand to do any operation.
suppose you have the following code for binary operation
C++ Syntax (Toggle Plain Text)
int result =0 , op1 = 3, op2= 4; result = op1 + op2; // the value of result will be 7 because '+' is a binary operator // 'op1' and 'op2' are the two operands
while in the case of unary operator
C++ Syntax (Toggle Plain Text)
int op1 = 10; op1++; // now the value of op1 is 11, because '++' is a unary operator // it involves only one operator, it adds a 1 to the 'op1' and put // that result back into 'op1'
Last edited by emarshah; Jun 26th, 2009 at 4:59 pm.
Syed Ammar Hassan
" A man is known by his level of Determinism "
--------------------------------------------------------
"Some cause happiness where ever they go, others whenever They go"
--------------------------XIII---------------------------
" A man is known by his level of Determinism "
--------------------------------------------------------
"Some cause happiness where ever they go, others whenever They go"
--------------------------XIII---------------------------
![]() |
Similar Threads
- Problem accessing private members and overloading operators (C++)
- Preprocessor definitions on the command line (C++)
- Help w/ dynamic list funtction definitions (C++)
- Zend PHP Certification (PHP)
- Unary operators (C++)
- accessing private data members (C++)
- probem with code of conditional operators (C)
- Data Abstraction (Computer Science)
Other Threads in the C++ Forum
- Previous Thread: push_back keeps reseting vector[0]! And it's really annoying !
- Next Thread: Seriously? Windows Winnie Tute
| Thread Tools | Search this Thread |
api array arrays based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion convert count data database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





