June 12, 2000

The binary_search Algorithm

STL’s binary_search() algorithm traverses a sequence and returns a Boolean value indicating whether the sought-after element exists in that sequence. binary_search() is declared in the header as follows: bool binary_search (ForwardIterator first, ForwardIterator last, const T& value) binary_search() takes two forward iterators that mark the sequence’s bounds, and the sought-after

Assigning a Specified Memory Address to a Pointer

In low-level programming and hardware interfaces, you often need to assign a pointer to a specific physical address. To do that, you have to cast the address value using the reinterpret_cast operator. Here’s an example that shows how this is done: void *p;// assign address 0x5800FF to pp = reinterpret_cast<

Useful STL Terminology

Here are some key terms that you may find useful for reading Standard Template Library (STL) literature and documentation. ContainerA container is an object that stores objects as its elements. Normally, it’s implemented as a class template that has methods for traversing, storing, and removing elements. Examples of container classes

Declarations With Implicit int Aren’t Permitted

Does your compiler accept the following declarations? volatile x; const y = 0; In pre-standard C++, the default type in such incomplete declarations was int. Thus, the first declaration would declare x as “volatile int” and y as “const int. ” However, according to the C++ standard, declarations with implicit

Blocking Object Copying and Assignment

To block copying and assignment of an object, explicitly declare the assignment operator and copy constructor private. Don’t define them, (there’s no point in defining them because they can’t be invoked anyway): only declare them. In the following example, class A has a public default constructor. In addition, it declares

Accessing SQL and Visual Basic

Question: I am developing a database program using Access and Visual Basic. I want to display data in a form where the data comes from two tables. For example, the Friends table has a City field and the City field has just CityID, which is linked to City table. I

Ordering Query Output By Two Fields

Question: I want to order the output of my query by two fields. Is this possible? That is, if two values are the same, I want the output ordered by a second field. Answer: The standard ORDER BY clause allows you to sort query output by one or more columns.

Datatype Decision

Question: I have a field that stores lots of data (up to 8,000 characters). I thought that I could maybe save disk space if I stored this data as varbinary versus varchar. Is this correct? If so, I would have to use CAST or CONVERT every time I wanted to

Autonumbering in SQL

Question: I am having to reformat data for addition to a database. My current struggle involves an identification field for certain records. In the new database it needs to be listed as an incrementing number with a “z” in front of it: for example, “z100.” Does Access allow an autonumber

No more posts to show