C++

View:  
Sorted by:  

Types of Constants in C++

A constant value in C++ is an explicit number or character (such as 1, 0.5, or ‘c’) that doesn’t change. As with variables, every constant has a type. In an expression such as [more…]

C++ Character Types

The standard char variable in C++ is a scant 1 byte wide and can handle only 255 different characters. This is plenty enough for European languages but not big enough to handle symbol-based languages such [more…]

Mixed Mode Expressions in C++

C++ allows you to mix variable types in a single expression. That is, you are allowed to add an integer with a double precision floating-point value. In the following expression, for example, [more…]

Perform Simple Binary Arithmetic in C++

A binary operator is one that has two arguments. If you can say var1 op var2, op must be a binary operator. The most common binary operators are the simple operations you performed in grade school. The [more…]

Determine the Order of Operations in C++

All operators perform some defined function in C++. In addition, every operator has a precedence — a specified order in which the expressions are evaluated. Consider, for example, how precedence affects [more…]

Perform Unary Operations in C++

C++ offers all the common arithmetic operations: C++ programs can multiply, add, divide, and so forth. Programs have to be able to perform these operations to get anything done. Arithmetic binary operators [more…]

Use Assignment Operators in C++

An assignment operator in C++ is a binary operator that changes the value of its left argument. The equal sign (=), a simple assignment operator, is an absolute necessity in any programming language. This [more…]

How to Create Your First C++ Program

The first step to creating a C++ program is to create what is known as a project. A project tells Code::Blocks the names of the .CPP source files to include and what type of program to create. Most of [more…]

How to Use Simple Logical Operators in C++

C++ programs have to make decisions. A program that can’t make decisions is of limited use. Invariably a computer program gets to the point where it has to figure out situations such as “Do [more…]

Store Logical Values in C++

The result of a logical operation in C++ can be assigned to a variable of type bool. The term bool refers to Boolean algebra, which is the algebra of logic. This was invented by a British mathematician [more…]

Risk of Logical Operations on Floating-Point Variables in C++

Round-off errors in floating-point computation can create havoc with logical operations in C++, so you must be careful performing logical operations on floating-point variables. Consider the following [more…]

Express Binary Numbers in C++

C++ variables are stored internally as so-called binary numbers. Binary numbers are stored as a sequence of 1 and 0 values known as bits. Most of the time, you don’t really need to deal with which particular [more…]

Control Program Flow in C++ with Branch Commands

The simplest form of flow control in C++ is the branch statement. This instruction allows the program to decide which of two paths to take through C++ instructions, based on the results of a logical expression [more…]

Looping While a Condition is True in C++

Branch statements allow you to direct the flow of a C++ program’s execution down one path or another. This is a big improvement but still not enough to write full-strength programs. [more…]

How to Use the Autoincrement/Autodecrement Feature in C++

C++ programmers very often use the autoincrement ++ or the autodecrement – – operators with loops that count something. Notice from the following snippet extracted from the [more…]

How to Use the For Loop in C++

The most common form of loop in C++ is the for loop. The forloop is preferred over the more basic while loop because it’s generally easier to read (there’s really no other advantage). [more…]

How to Apply Special Loop Controls in C++

C++ defines two special flow-control commands known as break and continue.Sometimes the condition for terminating a loop occurs at neither the beginning nor the end of the loop, but in the middle. Consider [more…]

Range of Numeric Types in C++

It may seem odd, but the C++ standard doesn’t say exactly how big a number each of the data types can accommodate. The standard speaks only to the relative size of each data type. For example, it says [more…]

Declare Variable Types in C++

In C++, variables must be declared and they must be assigned a type. Fortunately, C++ provides a number of variable types. See the table for a list of variables, their advantages, and limitations. [more…]

C++ Programming: 10 Anti-Hacker Tips

As a C++ programmer, you need to learn the things you should do in your C++ code to avoid writing programs that are vulnerable to hackers. There are also describes features that you can enable if your [more…]

Hacking: Example of SQL Injection into a C++ Program

Code injection occurs when the user entices your C++ program to execute some piece of user-created code. “What? My program would never do that!” you say. Consider the most common and, fortunately, easiest [more…]

How to Avoid Code Injection in C++

The first rule of avoiding code inject into C++ programs is never, ever, allow user input to be processed by a general-purpose language interpreter. A common error with SQL-injection is that the program [more…]

C++: The String Container

The most common form of a C++ array is the null-terminated character string used to display text, which clearly shows both the advantages and disadvantages of the array. Consider how easy the following [more…]

C++ Programming: The Hacker′s Motives

After you′ve finished a quick study of programming and sharpened your C++ skills, you land that really sweet job that you were looking for at the bank. You′re a big-time programmer at the bank, and you′ve [more…]

The C++ Template Library

The standard C++ library provides a complete set of math, time, input/output, and DOS operations, to name just a few. Many of the early programs that you learn as a beginner use the so-called character [more…]

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

Sign Up for RSS Feeds

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

Inside Dummies.com