Passing unmodifiable arguments as constobjects
Passing large objects by value as function arguments is very inefficient. On the other hand, passing them by reference/address is dangerous since it enables the callee to change its arguments
Passing large objects by value as function arguments is very inefficient. On the other hand, passing them by reference/address is dangerous since it enables the callee to change its arguments
Even experienced C++ programmers who have prior experience with C tend to use pointers excessively whereas references may be a better choice. Pointers may result in bugs like the following:
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
Using #define to create macro constants is not ideal. Macros are substituted by the preprocessor, so the compiler usually cannot detect anomalies such as type mismatch (see example); furthermore, most
One of the good things about destructors is that they are called automatically. There are rare cases, however, when you want to invoke an object
There are cases where you have to define several constructors (or constructors and operator = ) within one class, all of which perform some identical tasks (e.g., initialize members, allocate
Although Java’s String package is a lot more friendly than C’s string handling, you can still find yourself surprised by its behavior at times. Consider this code: import java.lang.String;public class
To present your applet in a visually pleasing way, it’s often handy to know the size of the screen that’s available for output. Fortunately, a built-in AWT function makes determining
Whenever you define a class member function which does not (and should not) change its object, it’s a good idea to define it as a const member function. There are