1

I'm learning C++, and by that I mean I've not made to page 20. However, I think I may have found a typo in the source material*, which naturally confuses and complicates the situation.

Without embarrassing the author further, I'll just say they write:

An array is a variable that can store multiple items of data - unlike a regular array, which can store one piece of data.

I know what an array and variable is. That's not my question. In the interest of clarification and learning, can I confirm that should read:

... - unlike a regular variable, which can store one piece of data.

Which makes sense to me.

*pun intended

Guillaume Racicot
  • 39,621
  • 9
  • 77
  • 141
Ghoul Fool
  • 6,249
  • 10
  • 67
  • 125
  • 2
    Going by just what you have presented your replacement is what I would do myself. Have you checked to see if there is an errata or a newer version of the book and see if the typo is mention/fixed? – NathanOliver Oct 15 '19 at 19:01
  • 2
    Seems reasonable. – Guillaume Racicot Oct 15 '19 at 19:01
  • Let's say, this is not the first edition :) and I may move on to another book at this point. – Ghoul Fool Oct 15 '19 at 19:02
  • 1
    well... nitpicking time: an array variable can store just one piece of data, like all other variable types in C++. It's just that this data is a "collection" of elements of other data type. Other variables types have this semantics too. – bolov Oct 15 '19 at 19:05
  • [The Definitive C++ Book Guide and List](https://stackoverflow.com/questions/388242/) – Remy Lebeau Oct 15 '19 at 19:05
  • @bolov point taken and duly noted, but for learning purposes that distinction was not made in the book. – Ghoul Fool Oct 15 '19 at 19:19
  • Don't attempt to learn C++ from random blog posts. It'll go wrong. – Lightness Races in Orbit Oct 15 '19 at 20:15
  • I'm sure you Googled the quote, only it's been lifted (with an extra spelling mistake) from a book, not a blog. I've changed tack and got a new, more comprehensive book out the library :) – Ghoul Fool Oct 16 '19 at 07:39

1 Answers1

4

Yes.

Let's forget anything we know about C++. Then an array cannot be "unlike a regular array". There definitely is a typo in this sentence.

We cannot know for sure what the author wanted to say, but your suggestion is an obvious one (assuming we remember again what we know about arrays and variables):

An array is a variable that can store multiple items of data - unlike a regular variable, which can store one piece of data.

This still isn't a very good explanation. It can be slightly misleading to say a variable of eg type std::string holds one piece of data (as it contains many characters, a size and possibly more). On the other hand, as someone suggested in a comment one could say that even a std::string (or an array) holds one piece of data just that this "one piece" happens to be a collection of things. Anyhow, the sentence is a bit sloppy and maybe it is not worth trying to interpret it too much.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185
  • @hyde I would prefer less handwaving in the first place. "one piece of data" is perfectly fine in colloquial language, but imho has no place in a book that tries to teach a language – 463035818_is_not_an_ai Oct 15 '19 at 19:28
  • @Adrian I didnt want to suggest "one piece of datum". This was just a minor nitpick. Will remove it from the answer, as it isnt essential – 463035818_is_not_an_ai Oct 15 '19 at 19:31