Question

In: Computer Science

In C++, the concept of a "bag" may be represented as (click all that apply): a...

In C++, the concept of a "bag" may be represented as (click all that apply):

a vector of pointers of a specific object type
a vector of objects
a vector of generic pointers
an array of whole numbers

The C++ keywords used to implement the principle of least privilege are (click all that apply):

public
#include
const
struct
ifndef
class

If a class Employee has a data member Date hireDate , and Employee's member functions need to access private data members of Date ... (click all that apply)

..Date has to declare the class Employee as its friend, or...
...Employee has to declare Date as its friend, or...
...trick question -- private members are accessible only by other members of the same class. That's the whole point of making members private.

What is the output from the code block below:

int i = 8;
cout << i++ << " ";
cout << ++i << endl;
8 10
9 10
9 9
8 9

Solutions

Expert Solution

Answers:

1) vector of pointers of a specific object type and a vector of objects

Explanation:

A bag can have different objects and there can be any number of objects. These objects can be of same type, or of different types. A vector is a container that can store elements. Thus, the vector is the bag, and the objects or the pointers of a specific objects type are the items inside a bag.

2) const

Explanation:

const can be used with a data member or a function to make them constant. It provides a read only access over them, and they cannot be changed once defined as const. Thus, it is the keyword to implement the principle of least privilege.

3) Date has to declare the class Employee as its friend

Explanation:

Private data members of a class can be accessed only by other members of the same class. If another class wants to access them, they have to be declared as its friend by the class holding the private data members. In this case, Employee class wants to access the private data member hireDate of the Date class. So, in order to do that, Date class has to delcare Employee class as its friend.

4) 8 10

Explanation:

i++ is defined as post increment, i.e., the value of 'i' will be printed first, and then incremented. ++i is defined as pre-increment, i.e., the value of 'i' will be incremented first, and then printed. In this case, the value of 'i' which is 8, is printed first and then incremented to 9. Then in the next line, it is incremented to 10 first, and then printed. Thus, the output is 8 10.


Related Solutions

In C++, the concept of a "bag" may be represented as (click all that apply): a...
In C++, the concept of a "bag" may be represented as (click all that apply): a vector of pointers of a specific object type a vector of objects a vector of generic pointers an array of whole numbers The C++ keywords used to implement the principle of least privilege are (click all that apply): public #include const struct ifndef class If a class Employee has a data member Date hireDate , and Employee's member functions need to access private data...
Discuss the concept of the risk-return trade-off and how it may apply in different circumstances.
  Discuss the concept of the risk-return trade-off and how it may apply in different circumstances.
1. Discuss the concept of the risk-return trade-off and how it may apply in different circumstances.
1. Discuss the concept of the risk-return trade-off and how it may apply in different circumstances. 2. Outline the risk-reduction benefits of diversification of an investment portfolio. In your answer, briefly discuss how portfolio diversification works in principle to minimise overall investment risk.
Why is ethical relativism a good concept to adopt? (Select all that apply.) A. We should...
Why is ethical relativism a good concept to adopt? (Select all that apply.) A. We should use different standards for different contexts B. Friends and family should be treated differently than coworkers C. Our reputation could increase D. One does not want an inconsistent outcome
Select all the answers that apply to modular design: 1. A module may not refer to...
Select all the answers that apply to modular design: 1. A module may not refer to other modules. 2. Modular design is an important part of procedural programming. 3. Modular design identifies the components of a program that can be developed independently. 4. Each module consists of a set of logical constructs that are related to one another. ///////////////////// Place the following parts of a function header into their correct order:       -       1.       2....
Provide a detailed explanation of concept of a Value Chain and apply the concept to a...
Provide a detailed explanation of concept of a Value Chain and apply the concept to a company of your choice
explain the democratic concept or principle represented in the Declaration of Independence and/or the Constitution.
explain the democratic concept or principle represented in the Declaration of Independence and/or the Constitution.
How does the going concern concept, consistency concept and accrual concept apply to the bankruptcy of...
How does the going concern concept, consistency concept and accrual concept apply to the bankruptcy of JC Penny due to the recent pandemic, COVID-19?
1. An inducer may affect gene expression by binding: (Select all that apply) A. Directly to...
1. An inducer may affect gene expression by binding: (Select all that apply) A. Directly to a consensus sequence on DNA B. An activator protein to remove it from the DNA C. A repressor protein to remove it from the DNA D. A corepressor E. An activator protein to help it bind DNA F. A repressor protein to help it bind DNA 2.What is the main difference between structural genes and control sequences in bacteria? Cite examples for both. 3.How...
1) Creation of an agency relationship may be by (choose all that apply) consensual agreement necessity...
1) Creation of an agency relationship may be by (choose all that apply) consensual agreement necessity operation of law conduct of the parties merger express contract estoppel ratification of an unauthorized act judgment 2) State and federal government statutes, doctrines and practices that affect many aspects of employment law include, but are not limited to, (choose all that apply) Civil Rights Act of 1964 Pregnancy Discrimination Act Occupational Safety and Health Act Equal Employment Opportunity Act Fair Labor Standards Act...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT