in healthcare is respect for patient autonomy—the right of patients to make decisions about their
own bodies and medical treatments. This principle is enshrined in the legal concept of informed
consent. Informed consent requires healthcare providers to disclose all relevant information about
the risks, benefits, and alternatives to a medical treatment or procedure, allowing patients to make
informed decisions.However, challenges arise when patients are not fully capable of making
informed decisions (e.g., due to age, mental illness, or language barriers). In such cases, ethical
dilemmas can arise regarding whether a third party (e.g., a parent or guardian) should make the
decision on the patient’s behalf, and whether the legal framework supports such decisions.#### 2.2
**End-of-Life Decisions and Euthanasia**End-of-life care, particularly decisions regarding
euthanasia, brings about significant ethical and legal debates. While some argue that individuals
should have the right to choose a dignified death through
Test Bank for
Problem Solving with C++: The Object of Programming, 10/Edition
Chapter 10 Defining Classes
TRUE/FALSE
1. A struct variable is declared differently from a predefined type such as an int.
ANSWER: FALSE
2. Two different structure definitions may have the same member names.
ANSWER: TRUE.
3. A structure can only be passed to a function as a call-by-value parameter
ANSWER: FALSE
4. A function may return a structure.
ANSWER: TRUE
5. Different class may not have member functions with the same name.
ANSWER: FALSE
6. A class member function may be private.
ANSWER: TRUE
7. Class data members are almost always public.
ANSWER: FALSE
8. It is possible to have multiple private labels in a class definition.
ANSWER: TRUE
9. The assignment operator may not be used with objects of a class.
ANSWER: FALSE
10. All constructors for a class must be private.
ANSWER: FALSE
11. A derived class is more specific than its parent, or base class.
ANSWER: TRUE
Short Answer
1. The keyword defines a structure type definition.
ANSWER: struct
2. A structure definition ends with the closing brace and a .
ANSWER: semicolon
3. A structure variable is a collection of smaller values called values
ANSWER: member
4. When a structure contains another structure variable as one of its members, it is
known as a .
ANSWER: hierarchical structure
, 5. When several items (variables or variables and functions) are grouped together
into a single package, that is known as .
ANSWER: (data) encapsulation
6. The double colon (::) is known as the operator.
ANSWER: scope resolution operator
7. Who can access private members in a class?
ANSWER: only other members of the class
8. A member function that allows the user of the class to find out the value of a
private data type is called a .
ANSWER: accessor function.
9. A member function that allows the user of the class to change the value of a
private data type is called a .
ANSWER: mutator function.
10. If you have a class with a member function called display(ostream& out), that will
send the values in the class to the parameter stream, and you need to call that
function from within another member function, how would you call it to print the
data to the screen?
ANSWER: display(cout);
in healthcare is respect for patient autonomy—the right of patients to make decisions about their
own bodies and medical treatments. This principle is enshrined in the legal concept of informed
consent. Informed consent requires healthcare providers to disclose all relevant information about
the risks, benefits, and alternatives to a medical treatment or procedure, allowing patients to make
informed decisions.However, challenges arise when patients are not fully capable of making
informed decisions (e.g., due to age, mental illness, or language barriers). In such cases, ethical
dilemmas can arise regarding whether a third party (e.g., a parent or guardian) should make the
decision on the patient’s behalf, and whether the legal framework supports such decisions.####
2.2 **End-of-Life Decisions and Euthanasia**End-of-life care, particularly decisions regarding
euthanasia, brings about significant ethical and legal debates. While some argue that individuals
should have the right to choose a dignified death through
11. What can a constructor return?
ANSWER: nothing
12. The name of a constructor is
ANSWER: the name of the class
13. The constructor of a class that does not have any parameters is called a
constructor.
ANSWER: default
14. In the following class constructor definition, the part of the header starting with a
single colon is called the .
BankAccount::BankAccount(): balance(0), interest(0.0)
ANSWER: initialization section
15. A class in which modifications to the implementation appear to be invisible to the
user of the class is known as .
ANSWER: an Abstract Data Type (ADT)
16. A member function that gets called automatically when an object of the class is
declared is called a .
ANSWER: constructor
17. If class A is derived from class B, then B is a of A.
ANSWER: parent
, 18. C++11 allows you to directly set the member variables to initial values in the
definition of the class. This feature is called .
ANSWER: member initializers
19. C++11 allows you to have a constructor call another constructor. This feature is
called .
ANSWER: constructor delegation
Multiple Choice
1. In a structure definition, the identifiers declared in the braces are called
a. classes
b. structs
c. member names
d. variables
ANSWER: C
2. You specify an individual member of a struct by using
a. the assignment operator
b. an ampersand
c. an underscore
d. The dot operator
in healthcare is respect for patient autonomy—the right of patients to make decisions about their
own bodies and medical treatments. This principle is enshrined in the legal concept of informed
consent. Informed consent requires healthcare providers to disclose all relevant information about
the risks, benefits, and alternatives to a medical treatment or procedure, allowing patients to make
informed decisions.However, challenges arise when patients are not fully capable of making
informed decisions (e.g., due to age, mental illness, or language barriers). In such cases, ethical
dilemmas can arise regarding whether a third party (e.g., a parent or guardian) should make the
decision on the patient’s behalf, and whether the legal framework supports such decisions.####
2.2 **End-of-Life Decisions and Euthanasia**End-of-life care, particularly decisions regarding
euthanasia, brings about significant ethical and legal debates. While some argue that individuals
should have the right to choose a dignified death through
ANSWER: D
3. To assign values to a structure variable, you use the
a. equals operator
b. assignment operator
c. extraction operator
d. less than operator
ANSWER: B
4. What is wrong with the following structure definition?
struct MyStruct
{
int size;
float weight;
}
a. Nothing
b. Can not have mixed data types in a structure
c. missing semicolon
d. Braces are not needed.
ANSWER: C
5. Given the following strucure definitions, what is the correct way to print the
person's birth year?
, struct DateType
{
int day;
int month;
int year;
}
struct PersonType
{
int age;
float weight;
DateType birthday;
}
PersonType person;
a. cout << person.birthday.year;
b. cout << year;
c. cout << birthday.year;
d. cout << peson.year;
ANSWER: A
in healthcare is respect for patient autonomy—the right of patients to make decisions about their
own bodies and medical treatments. This principle is enshrined in the legal concept of informed
consent. Informed consent requires healthcare providers to disclose all relevant information about
the risks, benefits, and alternatives to a medical treatment or procedure, allowing patients to make
informed decisions.However, challenges arise when patients are not fully capable of making
informed decisions (e.g., due to age, mental illness, or language barriers). In such cases, ethical
dilemmas can arise regarding whether a third party (e.g., a parent or guardian) should make the
decision on the patient’s behalf, and whether the legal framework supports such decisions.####
2.2 **End-of-Life Decisions and Euthanasia**End-of-life care, particularly decisions regarding
euthanasia, brings about significant ethical and legal debates. While some argue that individuals
should have the right to choose a dignified death through
6. Given the following strucure definition, what is the correct way to initialize a
variable called today?
struct DateType
{
int day;
int month;
int year;
}
a. DateType today(1,1,2000);
b. DateType today = (1,1,2000);
c. DateType today = {1,1,2000);
d. DateType today = {1,1,2000,0);
ANSWER: C
7. When defining a class, the class should be composed of the kind of values a
variable of the class can contain, and
a. member functions for that class
b. the keyword private
c. other class definitions
own bodies and medical treatments. This principle is enshrined in the legal concept of informed
consent. Informed consent requires healthcare providers to disclose all relevant information about
the risks, benefits, and alternatives to a medical treatment or procedure, allowing patients to make
informed decisions.However, challenges arise when patients are not fully capable of making
informed decisions (e.g., due to age, mental illness, or language barriers). In such cases, ethical
dilemmas can arise regarding whether a third party (e.g., a parent or guardian) should make the
decision on the patient’s behalf, and whether the legal framework supports such decisions.#### 2.2
**End-of-Life Decisions and Euthanasia**End-of-life care, particularly decisions regarding
euthanasia, brings about significant ethical and legal debates. While some argue that individuals
should have the right to choose a dignified death through
Test Bank for
Problem Solving with C++: The Object of Programming, 10/Edition
Chapter 10 Defining Classes
TRUE/FALSE
1. A struct variable is declared differently from a predefined type such as an int.
ANSWER: FALSE
2. Two different structure definitions may have the same member names.
ANSWER: TRUE.
3. A structure can only be passed to a function as a call-by-value parameter
ANSWER: FALSE
4. A function may return a structure.
ANSWER: TRUE
5. Different class may not have member functions with the same name.
ANSWER: FALSE
6. A class member function may be private.
ANSWER: TRUE
7. Class data members are almost always public.
ANSWER: FALSE
8. It is possible to have multiple private labels in a class definition.
ANSWER: TRUE
9. The assignment operator may not be used with objects of a class.
ANSWER: FALSE
10. All constructors for a class must be private.
ANSWER: FALSE
11. A derived class is more specific than its parent, or base class.
ANSWER: TRUE
Short Answer
1. The keyword defines a structure type definition.
ANSWER: struct
2. A structure definition ends with the closing brace and a .
ANSWER: semicolon
3. A structure variable is a collection of smaller values called values
ANSWER: member
4. When a structure contains another structure variable as one of its members, it is
known as a .
ANSWER: hierarchical structure
, 5. When several items (variables or variables and functions) are grouped together
into a single package, that is known as .
ANSWER: (data) encapsulation
6. The double colon (::) is known as the operator.
ANSWER: scope resolution operator
7. Who can access private members in a class?
ANSWER: only other members of the class
8. A member function that allows the user of the class to find out the value of a
private data type is called a .
ANSWER: accessor function.
9. A member function that allows the user of the class to change the value of a
private data type is called a .
ANSWER: mutator function.
10. If you have a class with a member function called display(ostream& out), that will
send the values in the class to the parameter stream, and you need to call that
function from within another member function, how would you call it to print the
data to the screen?
ANSWER: display(cout);
in healthcare is respect for patient autonomy—the right of patients to make decisions about their
own bodies and medical treatments. This principle is enshrined in the legal concept of informed
consent. Informed consent requires healthcare providers to disclose all relevant information about
the risks, benefits, and alternatives to a medical treatment or procedure, allowing patients to make
informed decisions.However, challenges arise when patients are not fully capable of making
informed decisions (e.g., due to age, mental illness, or language barriers). In such cases, ethical
dilemmas can arise regarding whether a third party (e.g., a parent or guardian) should make the
decision on the patient’s behalf, and whether the legal framework supports such decisions.####
2.2 **End-of-Life Decisions and Euthanasia**End-of-life care, particularly decisions regarding
euthanasia, brings about significant ethical and legal debates. While some argue that individuals
should have the right to choose a dignified death through
11. What can a constructor return?
ANSWER: nothing
12. The name of a constructor is
ANSWER: the name of the class
13. The constructor of a class that does not have any parameters is called a
constructor.
ANSWER: default
14. In the following class constructor definition, the part of the header starting with a
single colon is called the .
BankAccount::BankAccount(): balance(0), interest(0.0)
ANSWER: initialization section
15. A class in which modifications to the implementation appear to be invisible to the
user of the class is known as .
ANSWER: an Abstract Data Type (ADT)
16. A member function that gets called automatically when an object of the class is
declared is called a .
ANSWER: constructor
17. If class A is derived from class B, then B is a of A.
ANSWER: parent
, 18. C++11 allows you to directly set the member variables to initial values in the
definition of the class. This feature is called .
ANSWER: member initializers
19. C++11 allows you to have a constructor call another constructor. This feature is
called .
ANSWER: constructor delegation
Multiple Choice
1. In a structure definition, the identifiers declared in the braces are called
a. classes
b. structs
c. member names
d. variables
ANSWER: C
2. You specify an individual member of a struct by using
a. the assignment operator
b. an ampersand
c. an underscore
d. The dot operator
in healthcare is respect for patient autonomy—the right of patients to make decisions about their
own bodies and medical treatments. This principle is enshrined in the legal concept of informed
consent. Informed consent requires healthcare providers to disclose all relevant information about
the risks, benefits, and alternatives to a medical treatment or procedure, allowing patients to make
informed decisions.However, challenges arise when patients are not fully capable of making
informed decisions (e.g., due to age, mental illness, or language barriers). In such cases, ethical
dilemmas can arise regarding whether a third party (e.g., a parent or guardian) should make the
decision on the patient’s behalf, and whether the legal framework supports such decisions.####
2.2 **End-of-Life Decisions and Euthanasia**End-of-life care, particularly decisions regarding
euthanasia, brings about significant ethical and legal debates. While some argue that individuals
should have the right to choose a dignified death through
ANSWER: D
3. To assign values to a structure variable, you use the
a. equals operator
b. assignment operator
c. extraction operator
d. less than operator
ANSWER: B
4. What is wrong with the following structure definition?
struct MyStruct
{
int size;
float weight;
}
a. Nothing
b. Can not have mixed data types in a structure
c. missing semicolon
d. Braces are not needed.
ANSWER: C
5. Given the following strucure definitions, what is the correct way to print the
person's birth year?
, struct DateType
{
int day;
int month;
int year;
}
struct PersonType
{
int age;
float weight;
DateType birthday;
}
PersonType person;
a. cout << person.birthday.year;
b. cout << year;
c. cout << birthday.year;
d. cout << peson.year;
ANSWER: A
in healthcare is respect for patient autonomy—the right of patients to make decisions about their
own bodies and medical treatments. This principle is enshrined in the legal concept of informed
consent. Informed consent requires healthcare providers to disclose all relevant information about
the risks, benefits, and alternatives to a medical treatment or procedure, allowing patients to make
informed decisions.However, challenges arise when patients are not fully capable of making
informed decisions (e.g., due to age, mental illness, or language barriers). In such cases, ethical
dilemmas can arise regarding whether a third party (e.g., a parent or guardian) should make the
decision on the patient’s behalf, and whether the legal framework supports such decisions.####
2.2 **End-of-Life Decisions and Euthanasia**End-of-life care, particularly decisions regarding
euthanasia, brings about significant ethical and legal debates. While some argue that individuals
should have the right to choose a dignified death through
6. Given the following strucure definition, what is the correct way to initialize a
variable called today?
struct DateType
{
int day;
int month;
int year;
}
a. DateType today(1,1,2000);
b. DateType today = (1,1,2000);
c. DateType today = {1,1,2000);
d. DateType today = {1,1,2000,0);
ANSWER: C
7. When defining a class, the class should be composed of the kind of values a
variable of the class can contain, and
a. member functions for that class
b. the keyword private
c. other class definitions