devxlogo

October 10, 2000

Rethrowing a Throwable Exception in Your Code

Use the fillInStackTrace() method to rethrow a Throwable type of exceptional condition in your code. This is useful if you want to rethrow a exception that occurred while using a

Using dynamic_cast Properly

Programmers who use dynamic_cast sometime discover that their applications suffer from mysterious crashes although seemingly, they are bug free. In most cases, the reason is that they forgot to turn

Escape Sequences

Certain special characters are represented as escape sequences. An escape sequence begins with a (backslash) followed by an alphanumeric character. For example, the escape sequence represents the newline character. Note

Taking an Address of a Pointer

The sequence && is parsed as the logical AND operator. According to the Maximal Munch parsing principle, it’s never construed as two & (address of) operators: void func (char **

Invoking a Function Through a Pointer

When you call a function through a pointer to function, use that pointer as if it were the function itself, not a pointer. For example: #include char buff[10];void (*pf) (char

Assigning an Integer Value to an Enumeration

C++ doesn’t allow you to assign integer value to an enumeration directly: enum Direction (Up, Down};Direction dir;Dir=0; // error, can’t assign int to enum type However, you can use static_cast

Random Number Generator

Question: Is there a way to capture the last value (digit) of the system clock number and use that to generate a random number? Or look at system clock–find last

Free Store and Heap

Question: Is there any difference between heap and free store in C++? Answer: The free store is a region of memory from which a program allocates dynamic memory using new.

Servlet Variables

Question: If I declare one variable in a servlet class, and if I create many instances of that servlet, what will be the status of that variable? Answer: If the