May 1, 2001

DevX - Software Development Resource

Calling A Template Member Function

You can define a member function that is a template in a non-template class. For example: class A{public: template void func(); // member template }; How can you call such

DevX - Software Development Resource

Introducing Generators

A generator is a function or algorithm returning a series of values upon successive calls. The most common example is a random number generator although generators have many other useful

DevX - Software Development Resource

Converting char to wchar_t

The standard iostream family of classes defines the widen() member function which converts a single char to its wide-character equivalent. widen() has the following prototype: char_type widen(char c) const; The

DevX - Software Development Resource

Converting a hex String to int

In a previous tip, I showed how to convert a string containing a hexadecimal to int using the sscanf() function. stringstream objects can perform this feat too, in a more

DevX - Software Development Resource

Converting wchar_t to char

In addition to the widen() member function, the iostream framework supports the narrow() member function which performs the reverse operation, i.e., converting a wide character to its corresponding char value.

DevX - Software Development Resource

Verifying a Destructor’s Invocation

Conceptually, destructors of global objects are called after main() has exited. For this reason, many debugging and memory checking tools are confused and report phantom memory leaks or warn about

DevX - Software Development Resource

std::string and null Characters

Unlike C-strings, a std::string object may contain null characters in the middle of its internal buffer. For example: std::string s=