devxlogo

August 12, 2000

Functions Are Extern by Default

Unless explicitly declared static, an ordinary function is implicitly declared extern in C and C++. For example: extern void func(int i); // extern is redundant However, sometimes the extern qualifier

What You Can Learn from Compiler Warnings

The following code has a subtle bug. Can you detect it? DWORD ErrCode = GetLastError(); // Retrieve the error codeif (!ErrCode==ERROR_FILE_NOT_FOUND) // warning on this line Although the compiler cannot

Short-Circuiting String Comparison

Normally, you don’t need to implement operator == for comparing string objects, as it’s already defined for you. However, for certain applications, you might need to provide a different version

Optimize Oracle’s SQL Statement Cache

When Oracle receives a SQL statement to execute, it first looks to see ifthe execution plan already exists in its cache. If the statement does existin the cache, the previous

Move a Form by Clicking Anywhere on It

The following code allows you to move a form by clicking anywhere on the formand dragging it: Option Explicit’define module level variables to store the last position of the form,

Counting “Live” Instances of a Class

Counting the number of object instances of a certain class can be necessary in debugging and performance tuning. To do that, declare a static data member as a counter, and

Fix Single Quotes in a SQL Statement

The following will replace all single quotes in a SQL statement [CHR(39)] with anapostrophe [CHR(180)]. This is useful if you are trying to add names to adatabase as parameter values

How Many Digits Does a Floating-Point Variable Have?

The standard function template std::numeric_limits (defined in < limits >) returns the implementation-dependent number of digits that a certain type has: #include int main(){std::numeric_limits < float >::digits10; //6 on my