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
Problem 1 What is the difference between function declaration and function definition? 2 Write a recursive function to find sum of even numbers from 2 to 10. 3 List some


Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

write a c++ program which finds minimum of three numbers

O v e r l o a d i n g U n a r y Op e r a t o r s Us i n g F r i e n d F u n c t i o n cl a ss s i g n { i n t a ,

The ability to verify at run time the type of an object by using the typed operator or the dynamic_cast operator.

C Programming and Data Structures 1. Define and explain flow chart with an example. 2. Write an algorithm to print all even numbers in descending order and draw the flowcha

A: No.       While realloc() need to copy the allocation, this uses a bitwise copy operation, that will tear several C++ objects to shreds. C++ objects must be allowed to copy t

Selection Sort using this a nested for loop to iterate through and compare the array elements. If the value of an element with lower index is greater than the value of an element w

in this problem you are given a board in which some of the elements are placed..each element represent ancolor.fill the other elements in the board such that none of the adjacent e