GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 19-Feb-2008, 17:39
meili100 meili100 is offline
Junior Member
 
Join Date: Feb 2007
Posts: 37
meili100 has a little shameless behaviour in the past

Can "switch" based on std::string?


Code:
string x = "test1"; switch(x){ case "test1" : break; case "test2" : break; default : break; }

Why this doesn't work for the string?
  #2  
Old 19-Feb-2008, 17:53
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,303
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Can "switch" based on std::string?


Quote:
Originally Posted by meili100
Why...

Two strikes and you are out:
1. The switch condition must reduce to an integer value.
2. Case statement labels must reduce to integer constants.

Regards,

Dave
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find String In C++ muhiuddin C++ Forum 1 03-Feb-2008 11:30
Creating Variables based on user input oddsprite C++ Forum 9 01-Nov-2007 05:31
Help with a programm doom2006 C++ Forum 4 30-Sep-2006 23:58
GET A MASSIVE 25% DISCOUNT NOW (Choice of UK or USA BASED HOSTING) UWebSmart Web Hosting Advertisements & Offers 0 30-Jun-2006 08:18

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:02.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.