February 22, 2000

Dynamic Type Versus Static Type

The type of the most derived object to which an expression refers is said to be the dynamic type of that expression. For example, if p is declared as a pointer to class B and it’s actually pointing to an object of class D (when D is derived from B),

The replace() Algorithm

Another useful STL algorithm is replace(), which is defined in the standard header and has the following prototype: void replace (ForwardIterator start, ForwardIterator end, const T & old_value, const T & new_value); The first and the second arguments mark the sequence’s beginning and end, respectively. replace() changes every occurrence of

Bool Type Conversions

A value of type bool can be converted implicitly to a value of type int, with false becoming zero, and true becoming one. For example: bool b = false; int n = b; // n equals 0 b = true; double f = b; // f equals 1.0 Likewise, an

Swapping Two Variables Without Using a Temporary

The classic implementation of the swap algorithm looks like this: void swap (int & i, int & j) { int temp = i; i = j; j = temp; } Is it possible to swap i and j without using a third variable? Yes it is: swap(int & i, int

The Future of long

On 32-bit platforms, int and long usually occupy the same size. Programmers use these types interchangeably when they need a 32-bit integer. However, on 64-bit architectures, long is often represented as a 64-bit integer, whereas int occupies 32 bits. In the next few years, many platforms and processors will switch

Merging Two Lists

Merging two lists isn’t only a popular homework assignment; rather, this task is sometimes needed in real world programming as well. Fortunately, you don’t have to reinvent the wheel anymore. STL’s list defines the member function merge(), which takes a second list as an argument and merges it into the

Automatic Sorting After Inserting

Question: I have a datawindow with a few columns. I have written a menu through which I can sort the existing data alphabetically or by value. Whenever a new row is inserted, or an existing row is changed, I want the sorting to take place automatically. I do not want

Finding a SQL Builder Component

Question: I’m looking for an “SQL builder” component that I can plug into a VB application that is end-user-friendly. Essentially, I would like the component to allow users to use a graphical interface that represents the tables/views of an Informix DB with the output being a SQL statement. The resulting

Printing One Page of a Report

Question: How can I give the user the option to print only one page in a Visual FoxPro report? Answer: The REPORT FORM command has a RANGE parameter. Here is information from the help file: RANGE nStartPage [, nEndPage]Specifies a range of pages to print. nStartPage specifies the first page

No more posts to show