Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
Search the Tips
Tip Bank > C++ > Overloading

Overloading

1-20 of 36     Previous     Next
Overloading the const and non-const Member Functions
by Prashanth Narayanaswamy
We all know about the function overloading feature in C++, which allows us to have the same name given for a function with different signatures. But what about overloading based on the const-ness of a member function?
Detect an Operator Overloading a Class
by Vishakha Vaidya
Define the operator globally so that it accepts all user defined types in order to detect an operator overloading a class without the source for the class.
Visual Inheritance with C#
by Boris Eligulashvili
Microsoft VS.NET provides design-time support for form inheritance. A derived form can be added to your solution by right-clicking on your project in the Solution Explorer window and choosing "Add..." and then "Add Inherited Form…" from the context menu.
Simplify Operator Overloading
by Sophy Pal
Operator overloading may seem like a complicated task, but in fact, it's really simple. This tip describes two easy ways you can overload operators.
Avoid Empty Member Initialization Lists
by Danny Kalev
Following yesterday's tip, here's another deprecated habit that programmers should avoid. Consider the following class ...
Overloading Methods
by Jon Jagger
Suppose you are writing a method in a class that accepts a parameter of a given type. Such a method can also be called with an argument of a different type—as long as an implicit conversion ...
Invoking Overloaded Operators Explicitly
by Danny Kalev
The overloaded operator mechanism is "syntactic sugar" for ordinary function calls. You can always use the explicit name of an overloaded operator function to resolve ambiguities or document your ...
Equivalence Relationship in STL
by Danny Kalev
Certain STL containers and algorithms require that you overload operator < for the class type they store as elements in order to sort and compare these elements. Note that STL derives the equality ...
Deep Copy and Shallow Copy
by Danny Kalev
The terms "deep copy" and "shallow copy" refer to the way objects are copied, for example, during the invocation of a copy constructor or assignment operator. In a deep copy (also called "memberwise ...
Guidelines for Overloading the + Operator
by Danny Kalev
The built-in + operator is a binary operator that takes two arguments of the same type and returns the sum of its arguments without changing their values. In addition, + is a commutative operator. ...
Ensure Your Overloaded Subscript Operator Returns an Object by Reference
by Danny Kalev
When you overload the subscript operator, remember that the non-const version of the overloaded operator should return an object by reference, not by value. Otherwise, you won't be able to use it in ...
Overloading the Function Call Operator
by Danny Kalev
Overloading the function call operator can be somewhat confusing because the overloaded operator has two pairs of parentheses. It may not be immediately obvious which of these pairs declares the ...
Overloading the Subscript Operator the Right Way
by Danny Kalev
It is customary to overload the subscript operator, [], in classes that hold a sequence of elements. Vector and String are examples of such classes. When you overload operator [], remember to ...
Operators Can Only be Overloaded for User-Defined Types
by Danny Kalev
An overloaded operator must take at least one argument of a user-defined type (operators new and delete are an exception). This rule ensures that users cannot alter the meaning of expressions that ...
Overload New and Delete in a Class
by Danny Kalev
It is possible to override the global operators new and delete for a given class. For example, you can use this technique to override the default behavior of operator new in case of a failure. ...
Overloading Operators for enum Types
by Danny Kalev
For some enum types, it may be useful to define overloaded operators, such as ++ and --, that can iterate through the enumerator ...
Member and Non-Member Overloaded Operators
by Danny Kalev
Most of the overloaded operators can be declared either as non-static class members or as non-member functions. In this example, operator == is overloaded as a non-static class ...
Overloaded Operators May Not Have Default Parameters
by Danny Kalev
Unlike ordinary functions, overloaded operators cannot declare a parameter with a default value (overloaded operator() is the only ...
Overloading a Member Function Across Class Boundaries
by Danny Kalev
Since a class is a namespace, the scope for overloading a member function is confined to the class containing this function. Sometimes, it is necessary to overload the same function in its class as ...
Three Flavors of Polymorphism
by Danny Kalev
Polymorphism is the ability of different objects to react in an individual manner to the same message. This notion was imported from natural languages. For example, the verb "to close" means ...
1-20 of 36     Previous     Next
Sitemap