Question: Examine the following code. State what line 1 does, and state the outputs of lines 2 and 3 . include #include using namespace std; class

Examine the following code. State what line 1 does, and state the outputs of lines 2
and 3.
include
#include
using namespace std;
class Container{
private:
vector A;
public:
Container(const int size,int* array){
for (unsigned int i =0; i < size; i++)
A.push_back(*(array++));
};
int operator[](int index){ return A[index]* A[index];
}
int operator++(){return 5* A[2]; }
};
int main(){
const int ksize =3;
int array[ksize]={2,3,4};
Container A(ksize,array); // Line 1
cout << A[1]<< endl; // Line 2
cout <<++A << endl; // Line 3
}
3
2
2
c) When dealing with vectors, explain the difference between the functions size()
and capacity()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!