Design 6th Edition Malik Solutions Manual: C++ Programming From Problem Analysis To Program
Design 6th Edition Malik Solutions Manual: C++ Programming From Problem Analysis To Program
https://testbankfan.com/product/c-programming-from-problem-analysis-
to-program-design-6th-edition-malik-test-bank/
https://testbankfan.com/product/c-programming-from-problem-analysis-
to-program-design-7th-edition-malik-solutions-manual/
https://testbankfan.com/product/c-programming-from-problem-analysis-
to-program-design-8th-edition-malik-solutions-manual/
https://testbankfan.com/product/campbell-essential-biology-6th-
edition-simon-test-bank/
Computing Essentials Intro 2014 24th Edition OLeary
Solutions Manual
https://testbankfan.com/product/computing-essentials-intro-2014-24th-
edition-oleary-solutions-manual/
https://testbankfan.com/product/introduction-to-bankruptcy-law-6th-
edition-frey-test-bank/
https://testbankfan.com/product/framework-for-marketing-management-
global-6th-edition-kotler-test-bank/
https://testbankfan.com/product/consumer-behavior-6th-edition-hoyer-
solutions-manual/
https://testbankfan.com/product/moral-issues-in-business-australia-
new-zealand-3rd-edition-shaw-solutions-manual/
Logic of American Politics 8th Edition Kernell Test Bank
https://testbankfan.com/product/logic-of-american-politics-8th-
edition-kernell-test-bank/
C++ Programming: From Problem Analysis to Program Design, Sixth Edition 9-1
Chapter 9
Records (structs)
At a Glance
• Objectives
• Teaching Tips
• Quick Quizzes
• Additional Projects
• Additional Resources
• Key Terms
C++ Programming: From Problem Analysis to Program Design, Sixth Edition 9-2
Lecture Notes
Overview
In Chapter 9, students will be introduced to a data type that can be heterogeneous. They
will learn how to group together related values that are of differing types using records,
which are also known as structs in C++. First, they will explore how to create
structs, perform operations on structs, and manipulate data using a struct.
Next, they will examine the relationship between structs and functions and learn
how to use structs as arguments to functions. Finally, students will explore ways to
create and use an array of structs in an application.
Objectives
In this chapter, the student will:
• Learn about records (structs)
• Examine various operations on a struct
• Explore ways to manipulate data using a struct
• Learn about the relationship between a struct and functions
• Discover how arrays are used in a struct
• Learn how to create an array of struct items
Teaching Tips
Records (structs)
1. Define the C++ struct data type and describe why it is useful in programming.
Discuss how previous programming examples and projects that used parallel
Teaching
arrays or vectors might be simplified by using a struct to hold related
Tip
information.
3. Using the examples in this section, explain how to define a struct type and then
declare variables of that type.
1. Explain how to access the members of a struct using the C++ member access
operator.
C++ Programming: From Problem Analysis to Program Design, Sixth Edition 9-3
2. Use the code snippets in this section to illustrate how to assign values to struct
members.
Mention that the struct and class data types both use the member access
operator. Spend a few minutes discussing the history of the struct data type
and how it relates to C++ classes and object-oriented programming. Note that the
struct is a precursor to the class data type. Explain that the struct was
introduced in C to provide the ability to group heterogeneous data members
together and, for the purposes of this chapter, is used in that manner as well.
Teaching However, in C++, a struct has the same ability as a class to group data and
Tip
operations into one data type. In fact, a struct in C++ is interchangeable with
a class, with a couple of exceptions. By default, access to a struct from
outside the struct is public, whereas access to a class from outside the
class is private by default. The importance of this will be discussed later in the
text. Memory management is also handled differently for structs and
classes.
Quick Quiz 1
1. True or False: A struct is typically a homogenous data structure.
Answer: False
4. True or False: A struct is typically defined before the definitions of all the functions
in a program.
Answer: True
Assignment
1. Explain that the values of one struct variable are copied into another struct
variable of the same type using one assignment statement. Note that this is equivalent to
assigning each member variable individually.
Ask your students why they think assignment operations are permitted on
Teaching
struct types, but not relational operations. Discuss the issue of determining
Tip
how to compare a data type that consists of other varying data types.
Input/Output
1. Note that unlike an array, aggregate input and output operations are not allowed on
structs.
Mention that the stream and the relational operators can be overloaded to provide
Teaching
the proper functionality for a struct type and, in fact, that this is a standard
Tip
technique used by C++ programmers.
2. Illustrate parameter passing with structs using the code snippets in this section.
1. Using Table 9-1, discuss the similarities and differences between structs and arrays.
Spend a few minutes comparing the aggregate operations that are allowed on
Teaching structs and arrays. What might account for the differences? Use your previous
Tip exposition on the history of structs and memory management to facilitate this
discussion.
Arrays in structs
2. Using Figure 9-5, discuss situations in which creating a struct type with an array as a
member might be useful. In particular, discuss its usefulness in applications such as the
sequential search algorithm.
C++ Programming: From Problem Analysis to Program Design, Sixth Edition 9-5
structs in Arrays
1. Discuss how structs can be used as array elements to organize and process data
efficiently.
Emphasize that using a structured data type, such as a struct or class, as the
Teaching element type of an array is a common technique. Using the vector class as an
Tip example, reiterate that object-oriented languages typically have containers such
as list or array types that in turn store objects of any type.
1. Discuss how structs can be nested within other structs as a means of organizing
related data.
2. Using the employee record in Figure 9-8, illustrate how to reorganize a large amount of
related information with nested structs.
3. Encourage your students to step through the “Sales Data Analysis” Programming
Example at the end of the chapter to consolidate the concepts discussed in this chapter.
C++ Programming: From Problem Analysis to Program Design, Sixth Edition 9-6
Quick Quiz 2
1. What types of aggregate operations are allowed on structs?
Answer: assignment
3. True or False: A variable of type struct may not contain another struct.
Answer: False
Additional Projects
1. In Chapter 8, you were asked to write a program that keeps track of important birthdays.
Modify this program to store one person’s birthday information in a struct data type.
The struct should consist of two other structs: one struct to hold the person’s
first name and last name, and another to hold the date (day, month, and year). Consider
including other information as well, such as a vector of strings with a list of possible
gift ideas.
2. In Chapter 8, you were asked to write a program that listed all the capitals for countries
in a specific region of the world. Modify this program to use an array of structs to
store this information. The struct should include the capital, the country, and the
continent. You might include additional information as well, such as the languages
spoken in each capital.
C++ Programming: From Problem Analysis to Program Design, Sixth Edition 9-7
Additional Resources
1. Data Structures:
www.cplusplus.com/doc/tutorial/structures.html
2. struct (C++):
http://msdn2.microsoft.com/en-us/library/64973255.aspx
Key Terms
Member access operator: the dot (.) placed between the struct and the name of one
of its members; used to access members of a struct
struct: a collection of heterogeneous components in which the components are
accessed by the variable name of the struct, the member access operator, and the
variable name of the component
Discovering Diverse Content Through
Random Scribd Documents
“Butcha,” 326
Butchers, 299
Buttermilk, 171
Buy a horse, 206
grapes for wine-making, 229
Buying horses, 58
C⸺, Major, 3
Cah (Kah), 174
Calico printers, 200
rinsers, 193
Call to the bath, 72
Camel, bite of the, 243
fight, 242
tics, 392
Camels, mode of procuring fighting, 242
Campanile, the, Julfa, 157
Camp out, 348
Captain Burke, 344
Hansard, 343
S⸺, 179
T⸺, R.E., 278
Carapet, Mr., 357
Caravanserai Gulshan, 200
Mokhlis, 182
Carboys, 236
Card-playing, 96
Carpets, Persian, 149;
1883, 150
all wool, 151
Bath, 152
colours of, 150
fast colours, 149
faults in, 150
“Gelīm,” 152
increase in price of, 153
“Jejīm,” 152
Meshed, 149
mode of laying, 152
“Nammad,” 152
of great value, 151
of Mūrghāb, 151
old, 149
patterns of, 150
quality of, 150
value, 151
why they last, 150
Carvings, Abadeh, 332
Cashmere shawls, 274
Caspian steamer, 211
Cathedral of Julfa, 100
Cats, long-haired, 305
ordinary, 305
Causeways, 198
Cavalry, irregular, 266
Cells of students, 197
Cemetery, Armenian, 162
Chaff beds, 20, 25
Chah Ali Bunder, 275
Chambers, Captain, 127, 176
Character of Armenians, 316
Persians, 314
Char Bagh, 135, 196
Chardūr, 325
Chargāt, the, 322
Charlesiah, 132
Charms, 291
Cheap freehold, a, 206
Cheapness of ice, 240
Cheese, tale of the phantom, 172
Chelinjeh Khan, 223
Chess, 97
Chibouque, 32
Children, dress of, 325
Cholar wine, 229
grape, 232
Cholera, 224
Chuppering, rules of, 259
Chupper khana, interior, 25
a, 386
whip, 22
Church Missionary Establishment, 165
Church Missionary Schools, 144, 163
Church Missionary Society, educational work of, 144
Church of England, 166
Jesuits, 143
Civil suits, 189
Claim to sanctity of Armenians, 73
Classical Persian, 278
Clay biscuits, 334
Cleanliness of Persians, 316
Clemency, royal, 317
Climate, variable, 339
Clothes of Persians, 318
Cocculus indicus, 129
Coffee à la Turca, 6
Coinage, new, 371
Collars, difficulty of washing, 153
College at Ispahan, 196
Teheran, 338
Collins, Sergeant, 293
place of murder of, 351
Colonel Prideaux, 346
Colt, anecdote of a, 103
grey, 239
Comfort of travelling, 55
Common flowers, 172
Complexion of women, 324
Compliments, Persian, 28
Concubines, 326
Confiscation, 155
Constantinople, 5
Conversation with king’s son, 165
Cook, my, tries to take priest’s orders, 139
Cooks, 297
Cook-shops, 298
Coral reef, 342
Cossack regiments, 370
Cost of living, 186
Costume, Persian, 317
of women, 322
Court costume, 50
Courtiers, 199
Cream, mode of obtaining, 171
Credit, 188
Crickets, mole, 216
Crops, 173
Croquet lawn, 167
Crucifixions, 204
Cruelty to horses, 329
to a nun, 140
to Yari, 78
Cruelties to Mirza Naim, 272
Crying off, 188
Cucumber jam, 92
Cuisine, Persian, 296
Curdled milk, 171
Curio buying, 332
Curious accident, 128
ring, 376
Cursing Baab, 155
Curtain in Armenian church, 140
Custom-house, 267
Custom of Shiraz, 379
the Kūrūk, 370
Cut straw, 174
Cyrus, tomb of, 355
D⸺, Mr., 51
Damage to telegraph line, 113
Damascening, 189
Dar, the, 201, 282
Darius, treasure of, 78
Daroga, the, 371
Day in Ispahan, 200
Day of Judgment, picture of the, 161
Debauchee, a, 244
Decorated pond, 50
Decorations, church interior, 160
Dehbeed, 356
tax-man at, 133
Delleh, 69
Demarvend, 373
Dervish and puppets, tale of, 285
at tomb of Hafiz, 278
Dervishes, 42
at Tazzia, 281
garden, 46
hats, 44
horn, 46
mode of begging, 44
vices, 46
vows, 43
Desht-i-arjeen, 350
Diana, temple of, reputed, 107
Dig for treasure, we, 79
Dilgoosha, 220, 274
Dinner on road, 107
sent away, 245
with a Persian prince, 114
Discipline, 71
Disguise of robbers, 264
Dispensary, my, 200
over the prison, 182
Doctors, 33
Doctors, studies of, 338
Dog-cart, my, 248
Dog, loss of, 129
Dogs, varieties of, 306
Doherty, Mr., 401
Dome, tiled, 196
Donkeys, 365
handsome, 342
Doogh, 171
Doong, 391
Door, substitute for, 394
Doors at Erzeroum, 213
silver, 196
Double snipe, 107
Dozd-gah, 262
Dr. Hoernle, 163
Dr. Odling, 351
Dressel’s, 408
Dresses of honour, 51
Dress of dervishes, 43
Dried bread, 336
fruits, preparing, 169
Drink in Julfa, 141
Drive to Ispahan, 373
Drunkards, Persian, 141
Dubbeh, 188
Ducks, wild, 176
Dunaberg, 407
Dung beetles, 216
Duration of journey, 412
Durbend, 404
Dyah, 326
Dying twice, 203
G⸺, Colonel, 2
G⸺, Mr., 97
Gambling in Pera, 9
Game, 299
Games, 97
Gardening, 309
Garden-parties, 311
Gardens at Shiraz, 223
Gate of Royal Garden, 198
Gelim, 152
Georgian ladies, 17
Gersteiger Khan, the Baron, 370
Gez, 158, 383
Ghilān shoes, 399
Gholam, a bold, 178
Girls’ school, 165
Goggles, 54
Golden pipes, 112
Goldsmid, Sir F., 56, 157, 417
Goor Khur, 308
Gougas, 127
Governor of Fars, 135
Fussa, 244
Governor’s garden, 199
Grain, extracting, 174
stores, curious, 385
Grape feeding of horses, 103
sugar, 171
Grapes as horse feed, 171
varieties of, 171
Grateful Armenian, 93
Graves, Armenian, 162
Great square of Teheran, 52
Gregor, Saint, 160
Greyhounds, 305
“Grimes,” 344
Guebre-abad, 385
Guebre gardener, 369
Gulf Arabs, 106
Gulhaek, 369
road, 36
Gūlpigon, 127, 132
Gulshan caravanserai, 200
Gūmrūkji, anecdote of a, 237
Gun at sunset, 284
Gunge, a, 77
Guns, blowing from, 202
Gurken, 216
Gymnastics, 98
I am mobbed, 82
I am robbed, 263
Ibrahim, 383
Ice, cheapness of, 246
mode of making, 241
Ices, 240
I commence the cornet, 72
I decorate a house, 206
Idleness of Armenians, 359
I fall among brigands, 259
Illness, 207
of Zil-es-Sultan, 255
Imādieh, 118
Imād-u-Dowlet, 108
looted, 119
Imād-u-Dowlet’s bad son, 124
Imām-i-Juma, 153, 199
Imām Riza, 387
Imāmzādeh Hāshem, 400
Immorality of Armenians, 138
pigeon-flying, 94
Impregnable village, 262
Impromptu entertainment, 312
Indelicate dress of ladies, 40
Indian lottery, 340
Industry of Armenian women, 360
Infants, 325
Inlaid work, 332
Interest, rate of, 76
Interior of house of a grandee, 39
mosque, 97
Intricate carpentry, 39
Intrigues of Shiraz women, 276
Ironing, 333
Iron poles, 301
Irregular cavalry, 266
Irreligion common, 339
Irrigation, artificial, 127
Iskender, 378
Ispahan, 215
arrival at, 135
Ispahan bridge, 135
cobs, 105
Ispahani, honesty of, 192
Ispahan priests, 197
start for, 127
Istikhara, 277
Istikhbal, 56, 109
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
testbankfan.com