Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

nphuongsun93

  • 3 years ago

C++ Can anyone tell me why an error occurs when I declare something like string x = 0;?

  • This Question is Closed
  1. nphuongsun93
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Can string type take a value of a number?

  2. Shadowys
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    no. it's a string, so it is registered as a "string" of characters.

  3. charpede
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Strings in C++ end up as character arrays (from my experience). therefore, unless you are trying to make this a null string (in which case you should use ""; or null;) you generally want to surround your input with quotes as @nphuongsun93 stated previously. (which would make your right hand side be "0";)

  4. nphuongsun93
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Thank you very much.

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy