Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions