Message from C, C++ discussions

December 2019

— Hi good afternoon to everyone


I've got a problem while assigning "+2" to an int variable. I've looked it up on Google and I need to use string or something like that, which I do not really know how. So could someone help me out? Thank you so much!

— What do you mean with "+2"? Is it a positive integer? A string? Is your output a string that you need to convert to an int?

Message permanent page

— "+2" as if it was a word like "house". Well actually I want to assign "+2" to a position of a vector whose elements are integers

Message permanent page

— So you want to save the number 2

— No, i want to save "+2" which is not an integer, there comes the problem

— In a vector of integers?

— Yup

— You can't

— It's called vector of ints for a reason 🤔

— Even with strings?

— Create a vector of strings if you need that