Page 1 of 1

about ArrayString

Posted: Fri Dec 23, 2011 11:27 pm
by newbee
Hi,

Code: Select all

const wxArrayString choices;
choices.Add(wxT(“One”));
choices.Add(wxT(“Two”));
choices.Add(wxT(“Three”));
choices.Add(wxT(“Four”));
choices.Add(wxT(“Five”))
;

what is wrong with this?
my compiler says:
39 myapp.cpp passing `const wxArrayString' as `this' argument of `size_t wxArrayString::Add(const wxString&, size_t)' discards qualifiers

Re: about ArrayString

Posted: Fri Dec 23, 2011 11:43 pm
by doublemax
If a variable is "const", you can't make changes to it - that includes adding strings :)

Re: about ArrayString

Posted: Fri Dec 23, 2011 11:50 pm
by newbee
How stupid I am :oops: Maybe I should sleep.
Thank you,but its used in the book.(cross-platform gui programming with wxwidgets)