Overloading unary operators, C/C++ Programming

Overloading Unary Operators

class sign

{int a,b,c;

public:

sign(){}; sign(int,int,int); void putdata(void);

void operator-();

};

void sign::operator-()

{a=-a;b=-b;c=-c;           }

void sign::putdata(void)

{cout<<"a is: "<

}

sign::sign(int x,int y, int z)

{a=x;b=y;c=z;                          }

int main()

{           sign s; s=sign(1000,2,10); s.putdata();

-s; s.putdata(); cout<

s=sign(-2000,2,-5);

s.putdata();

-s;

s.putdata();

return 0;

}

Posted Date: 9/20/2012 8:17:37 AM | Location : United States







Related Discussions:- Overloading unary operators, Assignment Help, Ask Question on Overloading unary operators, Get Answer, Expert's Help, Overloading unary operators Discussions

Write discussion on Overloading unary operators
Your posts are moderated
Related Questions
A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Program of Binary tree: Btree::Btree(int O) : itemsInContainer(0) {     finishInit(O); }   Btree::~Btree(void) {     if( root != 0 )         delete roo

Dereferencing the Pointer this Sometimes a member function requires to make a copy of the invoking instance so that it can change the copy without affecting the original instan

Project Description: We refurbish older computer and send them back into the market with windows 7 operating system. We are presently using windows deployment services through P

Car Rental System This system tracks cars in a rental company. Each car has a number (assume its plate number), type (small car, four wheel car), and status (rented, available). T

(a) Write a procedure called (add x y) that adds two numbers in a recursive manner. Specifically, note that x + y = (x + 1) + (y - 1) and x + 0 = x. (b) Using the substitution m

THEORY OF COMPUTER PROGRAMMING

volume of a sphere

Define External Storage Class - computer programming? When a variable is declared outside a function the storage is permanently assigned to it and its storage class is 'extern'

A: It is implementation dependent. Verify with your compiler's documentation. For instance, assume you wish to do binary I/O using std::cin & std::cout. Unluckily there is no st