Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

nphuongsun93

  • one year ago

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

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

    Can string type take a value of a number?

  2. Shadowys
    • one year 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
    • one year 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
    • one year 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

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.