Sunday, 20 January 2013

Operator Overloading


By on 00:34

Operator Overloading:-Operator Overloading provides option for creation of new definition of Operators.Operator overloading provide special meaning to most of the operator like =,+,-,*,=+,== etc. but expect some operator.It is used in c ++,java,c#(c sharp) etc.


Some exception operators are:-

1)Scope Resolution Operator(::)
2)Sizeof operator
3)Conditional Operator(?:) 
4)Class member access point
5)Value of (*.)

Example:-Write a program to overload the unary operator "-"(you can also overload binary operator).

# include<iostream.h>
void<conio.h>

class xyz
{
int p,q,r;
public:
void get();
void put();
void operator-();
};
void xyz::get()
{
cout<<"enter no.";
cin>>p>>q;
}
void num::put()
{
cout<<p<<q<<r;
}
void xyz::operator-()
{
p=-p;
q=-q;
r=-r;
}
void main()
{
xyz x;           //object
clrscr();
x.get();
x.put();
-x;
x.put();
getch();
}



That's all about Operator Overloading(in oops and data structure).



If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.

2 comments:

  1. You made some good points there. I did a search on the topic and found most people will agree with your blog.Python Training in Chennai

    ReplyDelete
  2. This information is impressive; I am inspired by your post writing style & how continuously you describe this topic.... Java Training in Chennai | Python Training in Chennai

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...