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
}
Step-by-step 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.