APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY Previous Years Question Paper & Answer

Course : B.Tech

Semester : SEMESTER 6

Year : 2018

Term : MARCH

Scheme : 2015 Full Time

Course Code : EC 312

Page:4





PDF Text (Beta):

2a. The unary operators operate on a single operand and following are the
examples of Unary operators —

٠ The increment (++) and decrement (--) operators.
٠ The unary minus (-) operator.
٠ The logical not (!) operator.

The unary operators operate on the object for which they were called and
normally, this operator appears on the left side of the object, as in !obj,
obj, and ++obj but sometime they can be used as postfix as well like
obj++ or obj--.

Following example explain how minus (-) operator can be overloaded for
prefix as well as postfix usage.

#include

using namespace std;

class Distance {

private:
int feet; // 9 to infinite
int inches; 119 to 12
public:

// required constructors
Distance() {
feet = 0;
inches = 8;
}
Distance(int f, int i) {
feet = f;

inches = i;

Similar Question Papers