Best Windows Hosting

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Friday, 21 September 2012

10 Rules of Operator Overloading in C++

Posted on 04:53 by Unknown

Every programmer knows the concept of operation overloading in C++. Although it looks simple to redefine the operators in operator overloading, there are certain restrictions and limitation in overloading the operators. Some of them are listed below:

1. Only existing operators can be overloaded. New operators cannot be overloaded.

2. The overloaded operator must have at least one operand that is of user defined type.

3. We cannot change the basic meaning of an operator. That is to say, We cannot redefine the plus(+) operator to subtract one value from the other.

4. Overloaded operators follow the syntax rules of the original operators. They cannot be overridden.

5. There are some operators that cannot be overloaded like size of operator(sizeof), membership operator(.), pointer to member operator(.*), scope resolution operator(::), conditional operators(?:) etc

6. We cannot use “friend” functions to overload certain operators.However, member function can be used to overload them. Friend Functions can not be used with assignment operator(=), function call operator(()), subscripting operator([]), class member access operator(->) etc. 

7. Unary operators, overloaded by means of a member function, take no explicit arguments and return no explicit values, but, those overloaded by means of a friend function, take one reference argument (the object of the relevent class).

8. Binary operators overloaded through a member function take one explicit argument and those which are overloaded through a friend function take two explicit arguments.

9. When using binary operators overloaded through a member function, the left hand operand must be an object of the relevant class.

10. Binary arithmetic operators such as +,-,* and / must explicitly return a value. They must not attempt to change their own arguments.

Email ThisBlogThis!Share to XShare to Facebook
Posted in C++ | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Protecting E-mail Addresses on Webpages: Beware of using mailto protocol
    Placing an e-mail address on a Web page is a dangerous prospect nowadays. If the document on which the address appears generates even a medi...
  • DOM Events: Mouse Events, Keyboard Events, Form Events, Frame Events and Touch Events
    Mouse Events 1. Click Event (onclick): The event occurs when the user clicks on an element. 2. Double Click Event ( ondblclick):  The event...
  • Relation between Tablespace, Datafile and Control File
    Databases, tablespaces, and datafiles are closely related, but they have important differences: An Oracle database consists of one or more l...
  • Frameset, Frame and IFrame Elements in HTML
    Frame Element With frames, you can display more than one HTML document in the same browser window. Each HTML document is called a frame, and...
  • Hash Collision Attacks in .NET
    Hash collision attacks attempt to populate a hash-table within a server application with large numbers of items whose keys resolve to the sa...
  • Window Object in Javascript: Properties and Methods
    1 The Window object is the top level object and represents the window of the browser. 2. Window objects are either the current window (if th...
  • Response.Redirect vs Server.Transfer: What to use when? An 11 point comparision
    1. Response.Redirect simply sends a message to the browser, directing it to move to another page. Example: Response.Redirect("default.a...
  • 11 Commonly used AJAX Frameworks
    There are hundreds of AJAX Frameworks available. Most commonly used frameworks are jQuery, MooTools, Prototype, ASP.NET AJAX, Apache Wicket,...
  • GET vs POST: Which one is better? A 10 point comparision
    1. Data Size Restriction in GET: There is a character restriction of 255 in the URL. This is mostly the old browsers restriction and new on...
  • What is Garbage Collector? How and when does it run?
    The garbage collector takes care of bulk of the memory management responsibility, freeing up the developer to focus on core issues. The garb...

Categories

  • AJAX
  • C++
  • CSS
  • Delphi
  • DOTNET
  • HTML
  • Javascript
  • jQuery
  • Management
  • Online Degrees
  • Oracle
  • Others
  • Phonegap
  • PHP
  • Unix
  • XML

Blog Archive

  • ▼  2012 (155)
    • ▼  September (64)
      • Online Music Degrees
      • Online Accredited Degrees
      • Online Advertising Degrees
      • Online Finance Degrees
      • Online Marketing Degrees
      • Online Forensic Science Degrees
      • Online DBA (Database Administrator) Degrees
      • Online Biology Degrees
      • Online Geography Degrees
      • Online History Degrees
      • Online Art Degrees
      • Online Sports Degrees
      • Online Agriculture Degrees
      • Online Library Science Degrees
      • Online Environmental Science Degrees
      • Online Business Degrees
      • Online Physical Education Degrees
      • Online Science Degrees
      • 5 Tips to enjoy your workplace
      • 5 E-mail Etiquette You Must Know
      • How to grab the recruiter’s attention with your re...
      • 30 Facts About Google Adsense You Must Know
      • Working of the JSP Container
      • List of 70 basic commands of UNIX
      • 13 Point comparison between SQL and PLSQL
      • 10 Rules of Operator Overloading in C++
      • 6 Point comparison between Apache and IIS Web Servers
      • 5 Qualities of a good manager
      • Never try to fake your Resume / CV
      • How to write a cover letter of your resume?
      • The crucial first 5 minutes of an Interview
      • Rejected in an Interview? Don't Lose Your Heart
      • 6 FAQ’s in an interview
      • 5 ways to get into the good books of the boss
      • 5 Reasons to Quit Your Job
      • Online Web Designing Degrees
      • Online BBA Degrees
      • Online MA Degrees
      • Online BA Degrees
      • Online Human Resource (HR) Degrees
      • Online Graduate Degrees
      • Online Master Degrees
      • Online Fashion Design Degrees
      • Online Bachelor Degrees
      • Onlin PhD Degrees
      • Online Nursing Degrees
      • Online MBA Degrees
      • Online Doctorate Degrees
      • Online Psychology Degrees
      • Online Social Science Degrees
      • Online Law Degrees
      • Online Accounting Degrees
      • Online Medical Degrees
      • Online Engineering Degrees
      • Online Professional Degrees
      • 3 Things to keep in mind while you quit your job
      • Planning a job change? Tips to negotiate salary
      • How to use SaveToFile and LoadFromFile in Delphi XE2?
      • How to use TADODataset, TDatasource and TDBGrid in...
      • Embarcadero HTML5 Builder Features List
      • 5 ways to handle an interview over a video call
      • List of 8 job interview goof-ups
      • Anatomy of the commonly asked interview question “...
      • Use Social Networking Sites To Groom Your Career
    • ►  August (11)
    • ►  July (4)
    • ►  June (3)
    • ►  May (25)
    • ►  April (48)
Powered by Blogger.

About Me

Unknown
View my complete profile