When you choose to use an array to represent data, you are making a design decision
But design decisions should go beyond how data is stored; they should also involve how the data is used
Often, you’ll find it profitable to write specific functions to handle specific data operations
(The profits here include increased program reliability, ease of [...]
For file output, C++ uses analogs to cout
So, to prepare for file output, let’s review some basic facts about using cout for console output
(B-1):
You must include the iostream header file.
The iostream header file defines an ostream class for handling output.
The iostream header file declares an ostream variable, or object, called cout.
You must account [...]
Setting some format values, such as the field width, can be awkward using the iostream tools
To make life easier, C++ supplies additional manipulators in the iomanip header file (B-1)
(B-1) The three most commonly used manipulators (B-2)
setprecision() for setting the precision
setfill() for setting the fill character
setw() for setting the field width
(B-2) These manipulators take arguments
The setprecision() [...]
If you use iostream instead of iostream.h
You should use the following namespace directive to make the definitions in iostream available to your program (A-1):
This is called a using directive
Example of (A-1)
using namespace std;
Namaspace support
Is designed to simplify the writing of programs that combine preexisting code from several vendors
One potential problem is that you might use [...]
1. Start your programming environment and create a new project named ABCCS1.
Depending on your environment, if the file was not created already, then create a source file and save it as, or name it exercise.cpp
2. Set the file’s content as follows (A-1):
Example of (A-1)
#include <iostream>
using namespace std;
int main()
{
unsigned short shirts;
unsigned short pants;
unsigned short dresses;
unsigned short [...]
A namespace
A section of code
Delimited and referred to using a specific name
Give a common name to that portion of code so that, when referring to it, only entities that are part of that section would referred to
A namespace is created to
Set apart a portion of code with the goal to reduce, otherwise eliminate, confusion
How to [...]