September 25, 2000

DevX - Software Development Resource

Boolean Literals

The keywords false and true are Boolean literals that evaluate to 0 and 1 respectively. Note that in other programming language, VB for instance, false equals -1 and true equals

DevX - Software Development Resource

Casting Pointers To Members

C++ allows casting a pointer to member functions of one type to another pointer to member, as long as the signatures of the two match. However, the results of such

DevX - Software Development Resource

Hardcoded Char Arrays

Does your C++ compiler accept the following code? char s[3]=”abc”; // illegal in C++, no place for ” The standard requires that the size of a char array initialized with

DevX - Software Development Resource

Violating an Exception Specification

The implementation ensures that functions having an exception specification should throw only exceptions that are listed in their exception specification. For example: class X{};class Y{};void f() throw X{ throw Y();

DevX - Software Development Resource

Binding a Reference to an Rvalue

In a previous tip, http://www.devx.com/free/tips/tipview.asp?content_id=1585 , I explained the concept of lvalues and rvalues. Binding a reference to an rvalue is allowed as long as the reference is const. The

DevX - Software Development Resource

Extracting a Program’s Name

The name of the executable is stored in the string argv[0]. To access it, declare your main() function as follows: int main(int argc, char ** argv) Even if the application

DevX - Software Development Resource

Helper Functions

The interface of a class consists of its public members. Usually, private members represent implementation details and are not exposed to other classes and users. Private members can be member