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
Using a Friend Using a friend function is quite easy. The following example explains a friend function to access members of two classes. class Bclass;

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

convert lower case to uper case

What is Virtual Destructor? Describe it.

What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than a

Yes. "Memory pools" are useful in many situations. The bad news is that I'll need to drag you through the mire of how it acts before we talk about all the uses. Firstly, recall

Exceptions. Your SVector class should throw four exceptions: 3.1. If the constructor size is invalid, then it will just allow the implicit STL bad_alloc exception to pass up to mai

Part 1 Assignment:  develop a calculator in MASM. Text chapters covered:  1 through 4, 5.4, 5.5, 6.3, 7.4 You will develop a "calculator" algorithm in MASM using reverse-

1. Create text a file with the name "myemail" that has a single line in it, consisting of your email address. Something like "firstname_lastname@carleton.ca" (or your hotmail or gm

Described the ISA and HASA class relationships. How would you apply each in a class design? A: A specialized class "is" specialization of another class and, thus, has the ISA re