1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
iragen [17]
3 years ago
9

The pointer to the dynamic array is called data, and the size of the dynamic array is stored in a private member variable called

capacity. Write the following new member function: (C++ LANGUAGE)
void bag::triple_capacity( )
// Postcondition: The capacity of the bag's dynamic array has been
// tripled. The bag still contains the same items that it previously
// had.

Do not use the reserve function, do not use realloc, and do not cause a heap leak. Do make sure that both data and capacity have new values that correctly indicate the new larger array.
Computers and Technology
1 answer:
MatroZZZ [7]3 years ago
4 0

Answer:

Following are code to this question:

void bag::triple_capacity()//defining a method bag that uses the scope resolution operator to hold triple_capacity  

{

int* newArray = new int[3*capacity];//defining an array that holds capacity value

for(int x=0;x<capacity;x++)//defining for loop to hold array value

{

newArray[x] = data[x];//holding array value in newArray

}

delete[] data;//using the delete keyword to delete value in array  

data = newArray;//holding array value in data

capacity = capacity*3;//increaing the array size value

}

Explanation:

In this code, a method "bag" is declared that uses the scope resolution operator that holds the triple_capacity method, inside the method an array "newArray" is declared that uses the for loop to hold array value.

In the next step, the delete keyword is declared that delete data value and hold newArray value within it and at the last, it increases the capacity of the array.

You might be interested in
Which function key will help you find the word and replace
MaRussiya [10]

F5 key on your keyboard in word and power point if that is what you are referring to.


3 0
3 years ago
Assume that there is a class called BankAccountHolder that represents an individual member of a bank. There is also a BankAccoun
Elina [12.6K]

Answer:

Aggregation

Explanation:

In Java, Aggregation is a relationshipthat exists between two classes that is best described as a "has-a"

7 0
4 years ago
Read 2 more answers
What type of element addresses the recovery of critical information technology (it) assets, including systems, applications, dat
TiliK225 [7]

Disaster recovery type of element addresses the recovery of critical information technology (it) assets, including systems, applications, databases, storage and network assets.

<h3>What is disaster recovery plan in information technology?</h3>

A disaster recovery plan (DRP) is a formal document produced by an organization that contains explicit instructions on how to respond to unplanned happenings such as natural disasters, power outages, cyber-attacks and any other disruptive events.

<h3>What is a disaster recovery plan and why is it important to the organization?</h3>

A disaster recovery plan describes procedures for resuming work quickly and reducing interruptions in the aftermath of a disaster. It is an important part of the business continuity plan and it allows for sufficient IT recovery and the precluding of data loss.

To learn more about Disaster recovery, refer

brainly.com/question/24131287

#SPJ4

8 0
2 years ago
2. What is the name for an action performed by the VR Robot?
pychu [463]
Parameter is the answer you wanted
4 0
3 years ago
Read 2 more answers
When a user problem cannot be solved by the help desk at the first level of resolution, the problem is ___________ to the second
PIT_PIT [208]

Answer: escalated

Explanation:

7 0
3 years ago
Other questions:
  • Write a program that produces this output:
    10·1 answer
  • What does phishing mean?
    9·2 answers
  • Why do i get message notifications but when i click on it it says i have no new messages?
    7·1 answer
  • What is the education level of a majority of the Power, Structural, and Technical Systems workers?
    7·1 answer
  • What is the language of computers?
    9·1 answer
  • What are two design elements that help MRAP trucks resist mines?
    15·1 answer
  • Write a static method that takes a String and returns an integer. Return the number of characters in the passed in, String param
    6·1 answer
  • Can I control my digital footprint?
    9·2 answers
  • Need help with these plss correct answers
    13·1 answer
  • Answering a questi
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!