I am following along the great book C++17 by Example, which introduces C++17 by showcasing a series of mini projects -- very cool.
However, in chapter 2, where a Set is implemented on top of a LinkedList, there is this code:
void Set::read(std::istream& inStream) {
  int size;
  inStream >> size;
  int count = 0;
  while (count < size) {
    double value;
    inStream >> value;
    insert(value);
    ++count;
  }
}
void Set::write(std::ostream& outStream) {
  outStream << "{";
  bool firstValue = true;
  Iterator iterator = first();
  while (iterator.hasNext()) {
    outStream << (firstValue ? "" : ", ") << iterator.getValue();
    firstValue = false;
    iterator.next();
  }
  outStream << "}";
}
int main() {
  Set s, t;
  s.read(std::cin);
  t.read(std::cin);
  std::cout << std::endl << "s = ";
  s.write(std::cout);
  std::cout << std::endl;
  std::cout << std::endl << "t = ";
  t.write(std::cout);
  std::cout << std::endl << std::endl;
  // snip
}
I am fairly new to C++, and I do not know how to run this. Of course, I did some research before asking, but the way I came up with does not produce the expected results:
lambdarookies-MacBook:02-the-set-class lambdarookie$ ./02-the-set-class
1 2 3
3 4 5
s = {2}         // Expected: s = {1, 2, 3}
t = {3, 4, 5}
Now I am wondering:
- Is this simply not the right way to supply arguments, or
- it is the right way, and the bug must be elsewhere in the code?
 
     
    