[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a valid statement??
From: |
Dyreatnews |
Subject: |
Re: a valid statement?? |
Date: |
Tue, 29 Apr 2008 15:12:40 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (usg-unix-v) |
"jalqadir@gmail.com" <jalqadir@gmail.com> 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