• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++ help! *fixed*

screw3d

Diamond Member
I have this code..

when compiling through g++ 3.4.2, the line "numbers.push_back(32)" (second last line) generates this error:

19 passing `const std::vector<short int, std::allocator<short int> >' as `this' argument of `void std::vector<_Tp, _Alloc>:😛ush_back(const _Tp&) [with _Tp = short int, _Alloc = std::allocator<short int>]' discards qualifiers

What am I doing wrong? 😕
 
void splitToVectors(const vector<short> &number, int value) {
number.push_back(32); //why doesnt this work???
}

the reference number is a constant, but push_back modifies number. remove the const qualifier to fix
 
Originally posted by: dighn
void splitToVectors(const vector<short> &number, int value) {
number.push_back(32); //why doesnt this work???
}

the reference number is a constant, but push_back modifies number. remove the const qualifier to fix

Thanks 🙂

Found out why right before you posted! I wish the error messages are less cryptic :frown:
 
Back
Top