28 terms

Chapter 11 Structured Data

STUDY
PLAY
11.1 What are abstract data types?
Abstract data types are data types created by the programmer. ADTs have their own range (or domain) of data and their own sets of operations that may be performed on them.
p 593
11.1 An abstraction is...
a general model of something.
p 593
11.1 C++ has several primitive data types or
data types that are defined as a basic part of the language.
p 594
11.1 What are the different data types?
bool, int, unsigned long int, char, long int, float, unsigned char, unsigned short int, double, unsigned char, unsigned short int, double, short int, unsigned int, long double
p 594
11.1 A data type defines what....
values a variable may hold. Data types also define what values a variable may not hold. ex. int cannot hold a fraction
- Data types also define the operations that can be performed on a value.
p 594
11.1 Only int allows for the ___ operator.
%(modulus)
p 594
11.1 An abstract data type (ADT) is...
a data type created by the programmer and is composed of one or more primitive data types. In many cases, the programmer designs his or her own specialized operations.
p 594
11.2 C++ allows you to group several items together in a group known as a _________.
structure
p 595
11.2 To create a relationship between variables, C++ gives you the ability to...
package them together in a structure.
p 595
11.2 Before a structure can be used, it must be ________.
declared
p 595
11.2 The ___ is the name of the structure.
tag
p 596
11.2 The variable declarations which appear inside the braces of a structure...
declare members of the structure
p 596
11.2 A _________ is required after the closing brace of the structure declaration.
semicolon
p 596
11.2 Use uppercase when naming structures to...
visually differentiate them from variables
p 596
11.2 Structure definition is essentially creating...
a new data type.
p 596
11.2 Structure variables are actually made up of...
other variables known as members.
p 597
11.2 What is an instance of a structure?
An instance of a structure is a variable that exists in memory. It contains within it all the members defined in the structure declaration.
p 598
11.2 There are typically two steps to implementing structures in a program:
- Create the structure declaration. This establishes the tag (or name) of the structure and a list of items that are members.
- Define variables (or instances) of the structure and use them in the program to hold data.
p 598
11.3 What is the dot operator (.)
The dot operator (.) allows you to access structure members in a program.
p 598
11.3 The dot operator connects...
the name of the member variable with the name of the structure variable it belongs to.
p 598
11.3 With the dot variable you can use member variables like...
regular variables.
p 598
11.3 To display the contents of a structure you must...
pass each member separately to cout.
p 600
11.3 You cannot perform comparison operations...
directly on structure variables.
p 602
11.3 What is happening in this code segment?
if (circle1.radius == circle2.radius)
The code segment is comparing the radius, from a circle structure, of circle1 to the radius of circle2.
p 602
11.4 The members of a structure variable may be initialized...
with starting values when the structure variable is defined.
p 602
11.4 what is happening in this code?
struct CityInfo
{
string cityName;
string state;
long population;
int distance;
};

CityInfo location = {"Asheville", "NC", 50000, 28);
The structure CityInfo is created, with members for the name of a city, the name of the state, in which the city exists, the population of the city, and the distance from the city.

The variable location is initialized with all the needed data (as opposed to collected from the user)
p 602
11.4 You do not need to provide ____________ for all the members of a structure variable.
initializers
p 602
11.4 If you leave a structure member uninitialized, you must leave all other members which follow...
uninitialized. C++ does not provide a way to skip members in a structure.
p 603
YOU MIGHT ALSO LIKE...