C++

View:  
Sorted by:  

C++: Comparing Operators with Functions

The intrinsic data types are built into the C++ language, such as int, float, and double and the various pointer types. C++ enables the programmer to define the operators for classes that the programmer [more…]

C++ Programming: Operations on an Entire List

Some C++ programs can deal with data as it arrives and dispense with it. Most programs, however, must store data for later processing. A structure that is used to store data is known generically as a [more…]

C++ Programming: Make Your Way through a List

The C++ programmer iterates through an array by providing the index of each element. However, this technique doesn't work for containers like list that don't allow for random access. One could imagine [more…]

3 Tips for Using Templates in C++

A function template enables you to write something that looks like a function but uses one or more type holders that C++ converts into a true type at compile time. You should remember a few things when [more…]

What Are Exception Mechanisms in C++?

Occasionally functions don′t work properly — even for seasoned C++ programmers. The traditional means of reporting failure is to return some indication to the caller. C++ includes a mechanism for capturing [more…]

C++ Programming: Throwing Exceptions

A C++ function that allocates resources locally may need to catch an exception, do some processing, and then rethrow it up the stack chain. Consider the following example: [more…]

Why Does C++ Have a New Error Mechanism?

C++ uses the exception mechanism for errors. What′s wrong with error returns like FORTRAN used to make? Factorials cannot be negative, so you could have said something like “Okay, if [more…]

How Stream I/O Works in C++

Many beginning C++ programs read from the cin input object and output through the cout output object. Perhaps you haven't really thought about it much, but this input/output technique is a subset of what [more…]

C++: The Exception Mechanism

The next time you are examining a C++ code example, take a closer look at the steps that the code goes through to handle an exception. When the throw occurs, C++ first copies the thrown object to some [more…]

Open Modes in C++

This table shows the different modes in C++ that are possible when opening a file. However, you need to answer three basic questions every time you open a file: [more…]

What State Is a C++ File In?

A constructed C++ fstream object (including ifstream and ofstream) becomes a proxy for the file that it is associated with. For example, the stream object maintains state information about the I/O process [more…]

Methods of the C++ Stream Classes

The istream and ostream classes in C++ provide a number of methods, as shown in this table (this is not a complete list). The prototypes for these functions reside in the [more…]

Stream Input/Output in C++

The C++ classes ifstream and ofstream are subclasses of istream and ostreamdesigned to perform stream input and output to disk files. You can use the same extractors and inserters on [more…]

Default Stream Objects in C++

C++ adds a chunk of code to the front of your program that executes before main() gets control. Among other things, this code creates the default input/output objects shown in this table. [more…]

How to Use the Switch Statement in C++

The switch statement in C++ is a control statement that is useful in a limited number of cases. The switch statement resembles a compound ifstatement by including a number of different possibilities rather [more…]

How to Array the Arguments for Arrays in C++

An array is a sequence of variables in C++ that shares the same name and that is referenced using an index. Arrays are useful little critters that allow you to store a large number of values of the same [more…]

How to Use an Array in C++

An array is a sequence of variables in C++ that shares the same name and that is referenced using an index. The following C++ program inputs a sequence of integer values from the keyboard until the user [more…]

How to Initialize an Array in C++

In C++, a local variable does not start life with a valid value, not even the value 0. Said another way, a local variable contains garbage until you actually store something in it. Locally declared arrays [more…]

How to Create an Array of Characters in C++

The elements of an array in C++ can be of any type. Arrays of floats, doubles, and longs are all possible; however, arrays of characters have particular significance. [more…]

How to Create a String of Characters in C++

The elements of an array in C++ can be of any type. Arrays of floats, doubles, and longs are all possible; however, arrays of characters have particular significance. [more…]

How to Manipulate Strings with Character in C++

An array is a sequence of variables in C++ that shares the same name and that is referenced using an index. The following Concatenate program inputs two strings from the keyboard and concatenates them [more…]

How to Add Library Functions in C++

The C++ programmer is often required to manipulate zero-terminated strings. C++ provides a number of standard string-manipulation functions to make the job easier. A few of these functions are listed in [more…]

How to Make Room for Wide Strings in C++

The C++ programmer is often required to manipulate wide character strings. The standard C++ library includes functions to handle wide character strings. A few of these functions are listed in this table [more…]

Variable Size in C++

In C++, memory is measured in bytes or bits. The keyword sizeof returns the size of its argument in bytes. The following program uses this to determine the size of the different variable types: [more…]

Factoring and Inheritance in C++

The concept of inheritance, and thus factoring, in C++ allows one class to inherit the properties of a base class. Inheritance has a number of purposes; the main benefit of inheritance is the ability to [more…]

Listings:1-2526-5051-7576-100more...

Sign Up for RSS Feeds

Computers & Software
Great Gadget Giveaway -- Enter to Win!

Inside Dummies.com