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
Define a function PrintFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. Ex: PrintF
DaniilM [7]

Answer:

The function declaration to this question as follows:

Function declaration:

//declaring method printFeetInchShort, that accepts two integer parameters

void printFeetInchShort(int numFeet,int numInches) //method

{//method body

printf("The given height is: "); // message printing

printf("%d\'%d\" ", numFeet,numInches); //value printing

}

Explanation:

In the above method (function) declaration a method "printFeetInchShort" is declared, that accepts two integer variable as its parameters.

  • This method uses a return type void, which means it will not return any value.  
  • The parameter "numFeet and numInches" accepts an integer value in the main method and inside the method, it will print its value by a single and double quote.
5 0
3 years ago
Como se diz saia em inglês​
Montano1993 [528]

Answer:

I believe the translation would be "get out", but I'm not sure.

Explanation:

4 0
3 years ago
Read 2 more answers
if anyone is on a Chromebook, do you ever mean to press backspace, then you accidentally press the power button and think "OH CR
Pie

Answer:

every single day of my life

7 0
3 years ago
Read 2 more answers
6.5 Code Practice
o-na [289]

Answer: tried using stack over flow and GitHub. The have most of the codes for everything

Explanation:

4 0
3 years ago
What does a close observation of the painting reveal? the people's enjoyment of fishing as a pastime the people's reliance on th
Lana71 [14]
The peoples reliance on the sea industry
6 0
4 years ago
Read 2 more answers
Other questions:
  • On five lane roadways, the center lane is designated for __________ and is used by vehicles traveling in both directions.
    14·1 answer
  • The _________ contains approximately 200 million axons.
    13·2 answers
  • The _____ handles the instructions for your computer to start up before the operating system is loaded.
    11·1 answer
  • How does violating the SOLID principles make code hard to test?
    5·1 answer
  • Because all the IEEE WLAN features are isolated in the PHY and ____________ layers, practically any LAN application will run on
    11·1 answer
  • How do you chose a profile pic on brainly?
    8·1 answer
  • This assignment is based on Exercise 8.4 from your textbook. Each of the following Python functions is supposed to check whether
    11·1 answer
  • A folder is a collection of related of data is true or false​
    10·2 answers
  • What ethical concerns might arise from applying new IT to law enforcement?
    5·1 answer
  • Select 3 true statements about Python class.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!