Mar 2, 2018 at 6:25pm UTC
Consider the following class:
1: class GrabBag {
2: public:
3: void open();
4: void close();
5: bool isOpen();
6: void add (Junk j);
7: Junk removeRandomItem();
8: private:
9: vector<Junk> contents;
10: };
Which lines in this code contain a violation of const correctness?
Mar 2, 2018 at 6:28pm UTC
There's no constness there at all. No const - impossible to violate const correctness.
Mar 2, 2018 at 6:36pm UTC
In other words, (almost) every line is a potential violation.
You surely know what the const correctness means and therefore can explain whether it is possible to conclusively answer the question based solely on the class definition?
Mar 2, 2018 at 6:41pm UTC
its multiple choice and I can select any of them but I have to select at least one
Mar 2, 2018 at 6:56pm UTC
Which lines (intuitively) cannot be const? Why?
Mar 2, 2018 at 7:09pm UTC
Put another way, which of those functions look like they might try to change something in the class?