0% found this document useful (0 votes)
125 views

Unary Operators

Unary operators require a single operand and include operators like unary minus, unary plus, increment, and decrement. A function for a unary operator as a member function takes no arguments, while a function for a binary operator as a member function takes one argument, as binary operators require two operands like addition, subtraction, and comparison operators.

Uploaded by

Enrico Freefire
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

Unary Operators

Unary operators require a single operand and include operators like unary minus, unary plus, increment, and decrement. A function for a unary operator as a member function takes no arguments, while a function for a binary operator as a member function takes one argument, as binary operators require two operands like addition, subtraction, and comparison operators.

Uploaded by

Enrico Freefire
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Unary operators

The operator that requires only one operand to perform its


operations is known as unary operator.

Example: unary minus (-), unary (+), increment (++) and


decrement (--) etc.

Syntax,

Return type operator unary operator ()

{
Body;

Q. How many arguments are there in operator function defined


as member function for unary operators?

-> No argument

Q. Write a program to overload a unary minus operator (i.e.-)

Binary operator
The operator which requires two operands for its
operations is known as binary operators.
Example: binary plus (+), binary minus (-), greater than
(>), less than (<) and equality operator (==) etc.
Syntax,
Return type operator binary operator (argument list)
{

Body;

Q. How many arguments are there in operator function defined


as member function for binary operators?

-> One argument

You might also like