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

8
  • 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? Commented Oct 15, 2019 at 19:01
  • 2
    Seems reasonable. Commented Oct 15, 2019 at 19:01
  • Let's say, this is not the first edition :) and I may move on to another book at this point. Commented Oct 15, 2019 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. Commented Oct 15, 2019 at 19:05
  • The Definitive C++ Book Guide and List Commented Oct 15, 2019 at 19:05

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

@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
@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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.