"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > In my program I have the following statements > > void Person::setTitle(const Glib::ustring& str) { > switch ( str ) { > case "None" : { > title = title_t::None; > break; > } > case "Dr" : { > title = title_t::Dr; > break; > } > ...... > case "Rabbi" :{ > title = title_t::Rabbi; > break; > } > case "Shaykh" :{ > title = title_t::Shaykh; > break; > } > default : { > title = title_t::None; > break; > } > }// switch > }//Method > > when compiling I get an error code that reads: > ==== error: switch quantity not an integer ==== > Which is true, but according to > > http://newdata.box.sk/bx/c/htm/ch07.htm#Heading54 > > the error is unwarranted, since the parameter received by the method > and later on given to the switch statement for scrutiny is a valid C/C+ > + statement [setTitle(const Glib::ustring& str)]
Not true. The 2003-standard says "The condition shall be of integral type , enumeration type, or of a class type for which a single conversion function to integral or enumeration type exists" (6.4.2.2) > > Can anyone shed some light to this problem? It is also a problem that you are using string literals in your case labels. The case labels need to be an "integral constant expression" (6.4.2.2). And (5.19.1) spells out that a pointer is not. -- Dyre Tjeldvoll _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus