Tip Bank

DevX - Software Development Resource

A Null Preprocessor Directive

An empty # sign is a null preprocessor directive. A null directive has no effect but you can use it to document your intentions, for example: ifndef HEADER_INCLUDED#define HEADER_INCLUDED#else# //

DevX - Software Development Resource

Wide-char File Streams

The library supports two types of file streams: char-based streams such as std::ifstream and whcar_t streams. The names of wchar_t streams are the same as their char-based counterparts, except that

DevX - Software Development Resource

Repositioning a std::fstream Pointer

Just like the fseek() function of , classes enable you to position the stream’s pointer at an arbitrary location by calling the seekg() member function. For example, you can position

DevX - Software Development Resource

char[] vs. char *

C++ forbids direct assignments of arrays. Therefore, your compiler will flag the following code as an error: char buff[];buff=

DevX - Software Development Resource

Optimizing the Use of std::string

Here a few guidelines for improving std::string’s performance and avoiding common pitfalls. Consider the following for-loop: std::string str =

DevX - Software Development Resource

Pointers and Arrays

C++ never passes arrays to a function. Instead, the argument is implicitly converted to a pointer that contains the address of the first array element. For example: void f(char s[]);int

DevX - Software Development Resource

Using a Template Member Function

An ordinary class may have template member functions. In the following example, the class A declares a template member function called f(): class A{public: template T f(T t);}; You may

DevX - Software Development Resource

Template Parameters and Template Arguments

The terms template argument and template parameter do not mean the same thing. A template parameter is a symbol, or a placeholder which is replaced by the actual argument when

DevX - Software Development Resource

To DLL or not to DLL?

Many Windows programmers use DLLs abundantly. Although dynamic linking certainly offers some advantages, it can also cause noticeable maintenance and performance setbacks. For starters, DLLs are slower than statically linked