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]
2 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]2 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
Consists of a variety of circuitry and components that are packaged together and connected directly to the motherboard. it perfo
Goshia [24]
This is true because the motherboard is the main holder of all the operation and connection of all the system.
3 0
3 years ago
¿Cuál crees tú sea la finalidad de los virus informático, y porque son creados? ¿Cuáles son las precauciones y / o recomendacion
pantera1 [17]

Un virus informático es un tipo de programa de software malicioso ("malware") que, cuando se ejecuta, se replica modificando otros programas informáticos e insertando su propio código. Cuando esta replicación tiene éxito, se dice que las áreas afectadas están "infectadas" con un virus informático.

Un virus informático es un tipo de programa de software malicioso ("malware") que, cuando se ejecuta, se replica modificando otros programas informáticos e insertando su propio código. Cuando esta replicación tiene éxito, se dice que las áreas afectadas están "infectadas" con un virus informático.

lo mejor es mantener tu computadora actualizada

6 0
3 years ago
In programming, what is a string?
Alla [95]

A way to store a sequence of letters, numbers or symbols.

This is the most accurate statement, though not entirely true.

Hope this helps.

7 0
3 years ago
Read 2 more answers
List some of the cautions related to costume change
Volgvan

Answer:

Costume Change?

Explanation:

You might not have enough time to complete the costume and it may look a little sloppy. Also, if you are in a play, everyone must be notified of the change.

4 0
2 years ago
Which of these monitor connector types is the oldest and least desirable to use?
ella [17]

Answer:

DVI is the oldest out of the four.

Explanation:

DVI and VGA are the oldest, but DVI is oldest and least desirable to use since it is outdated.

5 0
3 years ago
Read 2 more answers
Other questions:
  • A digital footprint is all of the information on-line about a person posted by that person or others, ____________. intentionall
    14·1 answer
  • Can anybody come up with a catchy title for this?
    11·1 answer
  • How long will twenty percent of battery life last me?
    14·2 answers
  • Write a program that uses for loops to perform the following steps: Prompt the user to input two integers: firstNum and secondNu
    15·1 answer
  • What is the final value for X ?<br><br> x= 1<br><br> x=13<br><br> x= x+3<br><br> x=0
    9·1 answer
  • Write a program that takes paragraph from the user and prints all unique words in that paragraph using strings in c++
    5·1 answer
  • I need a C++ program to ask the user to put in different numbers until zero is pressed then the program counts the numbers that
    10·1 answer
  • Is it possible to code your own game and if so then where should I go to learn and how to publish it?
    12·2 answers
  • Refer to the exhibit. Host B on subnet Teachers transmits a packet to host D on subnet Students. Which Layer 2 and Layer 3 addre
    11·1 answer
  • A technique that was developed to determine whether a machine could or could not demonstrate the artificial intelligence known a
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!