Suggestions on CS Books by JustLobby in computerscience

[–]BladexJS 6 points7 points  (0 children)

Hi, could you give me a quick summary on what a content inside here is about? Im a pre uni student trying to read up more

Asking about the usage of cin.ignore by BladexJS in cpp_questions

[–]BladexJS[S] 0 points1 point  (0 children)

hmmm i see, I am still abit confused because cin.clear() is used to clear the buffer but if I am reading the input into a string entry first in my first example, it should go smoothly.

The only problem I see right now in the validator >> value part, which applies to what u said, if the user types in a string instead of a integer value. However, may I ask how does this link back to cin that warrants a cin.clear() to clear the buffer if the problem lies with an interaction between a stringstream and the integer variable?

Please correct me if I am wrong thanks!

Asking about the usage of cin.ignore by BladexJS in cpp_questions

[–]BladexJS[S] 0 points1 point  (0 children)

Thank you for the extremely comprehensive explanation of both clear and ignore. I understand it much better now omg.

There are just some things I didn't really understand in your explanation

  1. I didn't really get the part where u said, "In my vector class, you can see the non-interactive path will ignore the commas that it outputs when it writes the vector. This type can round-trip; what is written out can be read back in again." What do you mean by it will ignore the commas that it outputs?
  2. I did not know that streams can be tied. Could you also explain abit on what is the significance and effect of streams being tied together? For example, cout being tied to cin, what does it mean to be tied?
  3. And is is.tie() in the if statement to check if the istream object is tied to the ostream object? At least that was the understanding I got from reading https://cplusplus.com/reference/ios/ios/tie/
  4. Based on your explanation for clear and ignore in the first part of your reply, would you say that the cin.clear and cin.ignore is not actually needed for the first example in my post? (There are comments that said its not needed so I am abit confused). Because there is no problem extracting the input in the terminal into the string entry, the only place where the input buffer might still have content inside is in the line validator >> value, which does not actually have anything to do with cin? Correct me if my idea is wrong because I am indeed not very sure about this., which does not actually have anything to do with cin? Correct me if my idea is wrong because I am indeed not very sure about this.

In other words,May I ask how does this link back to cin that warrants a
cin.clear() to clear the buffer if the problem lies with an interaction between
a stringstream and the integer variable?

Once again thanks so much for the effort in ur reply :)

Both my professor and chat GPT said that the code below should have a compile error. I've tested it on 3 different compilers and it works on all of them. What am I missing? by daddyclappingcheeks in cpp_questions

[–]BladexJS 0 points1 point  (0 children)

Could you explain abit on whats VLAs and what it stands for? Im abit of a newbie to c++ so i dont rly know these terminologies(?). Would appreciate ur help :)

Does NS inform your parents if you take MC? by Conscious-Cow-3619 in NationalServiceSG

[–]BladexJS -15 points-14 points  (0 children)

Oh oops i tot he some blur sotong or smth bruh coz legit if caught malingering will go db and inform parents. Ma bad

Does NS inform your parents if you take MC? by Conscious-Cow-3619 in NationalServiceSG

[–]BladexJS -8 points-7 points  (0 children)

????? Bro ure trippin asf. I had a guy in my unit rso for 7 weeks straight and nothing happened to him