473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

a question about switch()

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)]

Can anyone shed some light to this problem?
Jun 27 '08 #1
2 1715
ja******@gmail.com wrote:

[switching over string]
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)]

Can anyone shed some light to this problem?
Your aforementioned source is distributing misleading informations. The
condition expression over the switch statement has to be of integral or
enumeration type or a class type with a single conversion to an
integral or enumeration type and the label expressions have to be
integral constant expressions. No character literals, structs, doubles
or the alike.

--
IYesNo yes=YesNoFactory.getFactoryInstance().YES;
yes.getDescription().equals(array[0].toUpperCase());
Jun 27 '08 #2
On Apr 29, 1:27 pm, Marco Manfredini <ok_nospam...@phoyd.netwrote:
jalqa...@gmail.com wrote:
[switching over string]
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)]
Can anyone shed some light to this problem?
Your aforementioned source is distributing misleading informations.
That's putting it mildly. It's full of a lot of partial
information, and very, very dated. To be avoided.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
4
by: Yu Hu | last post by:
Hello, Is it legal (and moral) to assign a method pointer with the proper prototype to a variable whose type involves the superclass? (Sorry if my wording of the question is imprecise, I'm not...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
6
by: Aristotelis E. Charalampakis | last post by:
Hi all, this is a newbie question :-) I was wondering if there was a way to use the switch statement in a manner that each case statement includes more that a simple value. i.e.: switch (...
11
by: Capstar | last post by:
Hi, I am working on an application, which will run embedded without an OS. The app is build up out of a couple of well defined parts. At first I wanted to keep those parts seperated and use...
0
by: Joseph S. | last post by:
hi all, debugging PHP applications interactively is possible, easy and free. I am talking about PHPEclipse and using it for debugging over several scripts or debugging through a session. Since I...
11
by: Sensei | last post by:
Hi again! I have still curiosity about the reason of some C constructs/keywords... The first is about static functions. What was the reason of restricting a function to be visible just in a...
6
by: Wescotte | last post by:
I'm having an issue where what should be global variables are not in scope and I'm confused as to why. In Case 1 the variables are not in scope for functions in File2 In Case 2 the varibales are...
3
by: spacedrabbit | last post by:
hello, this is my first post on the site. im a senior in college and decided that a comp sci minor in my last year would be a good idea... right now im teaching myself c to try to place out of the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.