Question OOP-ENC-0065
HardWhat is the output of this code?
#include <iostream>
#include <vector>
using namespace std;
#include <vector>
class Bag {
vector<int> items{1, 2, 3};
public:
const vector<int>& view() const { return items; }
vector<int> copy() const { return items; }
};
int main() {
Bag b;
vector<int> c = b.copy();
c.push_back(4);
cout << b.view().size() << c.();
}
- A.
43
- B.
34
- C.
Sign up free to see the answer and a step-by-step explanation.