DEV Community

Discussion on: C++ from the beginning - control flow

Collapse
 
sandordargo profile image
Sandor Dargo

I'd like to add two comments.

  • There is a typo in your last example, it's push_back not push_item.
  • Once the typo is fixed, that example generates a compiler warning which is hopefully treated as an error. std::vector::size() returns a size_type (size_t) that is unsigned, while int is a signed type. Comparing differently signed ints is error-prone, hence the warning/error.
Collapse
 
softchris profile image
Chris Noring

Appreciate your comment Sandor. Let me update