Login | Register   
LinkedIn
Google+
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++ > Operators

Operators - Page 3

41-60 of 60     Previous     Next
User-Defined New and Delete Cannot be Declared in a Namespace
by Danny Kalev
Operators new and delete can be declared in a class scope. However, the Standard prohibits declarations of these operators in a namespace. Why is this? Consider the following example: ...
Restrictions on Operator Overloading
by Danny Kalev
The following restrictions apply to operator overloading: ...
Prefix Versus Postfix Operators
by Danny Kalev
You can use both -- and ++ as prefix and postfix operators. When applied to primitives such as int or char, they are indistinguishable in terms of efficiency. When applied to objects, on the other ...
Simulating Inheritance of Assignment Operator
by Danny Kalev
As opposed to base class' constructor and destructor, which are automatically invoked from the derived class' constructor and destructor respectively, a user-defined assignment operator defined in a ...
Beware of Aliasing
by Danny Kalev
Whenever your class contains pointers, references, or handles, you need to define a copy constructor and assignment operator. Otherwise, the compiler-generated copy constructor and assignment ...
Consistent operator overloading
by Danny Kalev
Whenever you overload operators such as + or -, it is useful to support the corresponding += and -= as well. As opposed to a common belief, the compiler will not do that for you ...
Assignment operator is not inherited
by Danny Kalev
Unlike ordinary base class member functions, assignment operator is not inherited. It may be re-defined by the implementer of the derived class or else it is automatically synthesized by the ...
Overloading postfix and prefix ++
by Danny Kalev
For primitive types the C++ language distinguishes between ++x; and x++; as well as between --x; and ...
Testing the Copy Constructor and the Assignment Operator
by Karsten Weihe
You have written a test program for your class X, and ...
vector<> members must define < and == operators
by Danny Kalev
The STL vector<>, as well as other standard containers, support comparison and sorting of their members by calling the corresponding standard functions found in the <algorithm> header ...
One more thing to remember when defining copy constructor and operator=
by Danny Kalev
Assigning an object to itself is disastrous, so whenever you have to define a copy constructor and assignment operator, make sure your code is guarded from such a ...
Operator overloading rules of thumb
by Danny Kalev
When overloading an operator to support a user-defined type (object), it is best to adhere to the basic semantics of that built-in operator. For instance, the built-in operator ==, which does not ...
Conversion Operators
by Danny Kalev
Sometimes, an object must be converted into a built-in type (for instance, a string object passed as an argument to C function).
Copy constructor and operator= go together
by Danny Kalev
If you do not define a copy constructor and operator = , the compiler will create them automatically for you. However, there are cases when you have to define them explicitly. In such ...
Reference Counted Implementation
by DevX Pro
For a reference counted implementation, how is the operator+= member function coded? The function receives (const String & rhs) and returns String &. The returned String &String &
What to do with overload arguments
by DevX Pro
Which arguments do you receive when you overload . and -> , and what do you do with the arguments? I know that for overloading [] you receive the index. How about . and -> ?
How does one overload operator->*()?
by DevX Pro
How does one overload operator->*()?
I get a runtime error when I use the array delete operator
by DevX Pro
This is legal (safe) and works with the compiler environment I am using: CMyObject *ptr = NULL; delete ptr; However, I get a run-time error (assert) when I use the array delete operator: long *array = NULL; delete [] array; Is the environment right or is it legal C++ to use array delete on a NULL pointer?
Calling the Operator =
by DevX Pro
How can I call the operator= of the base class from the operator= in the derived class? The data member in the base class is a private data member. I want to be able to use operator = in the derived class and call the operator = in the base class
Sending output to the standardprinter
by DevX Pro
How do I send the output of my program to the standardprinter installed in Win95 or NT? Is it possible using the
41-60 of 60     Previous     Next
Sitemap