Game Development Reference
In-Depth Information
Listing 3-14. The ~ Operator
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int test = 0x0000000F;
cout << hex << ~test;
return 0;
}
This program will write out 0xFFFFFFF0, which is the value 0x0000000F with all of the bits flipped from
0 to 1 and 1 to 0.
Summary
In this chapter we have covered all of the basic operators that we will be using to construct
procedural programs. These operators allow us to carry out arithmetic on variables, compare the
relationships between values in variables, and even carry out complicated operations on individual
bits inside variable values.
Every program we write uses combinations of these operators to carry out complicated and complex
tasks. The examples so far in this topic have been basic programs that help us to understand the effects
of these operators on the types provided by the C++ programming language. The examples beginning
in Chapter 4 will actually start us on our journey into creating a text adventure game using C++.
 
Search WWH ::




Custom Search