CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2006
    Posts
    141

    Can "switch" based on std::string?

    Code:
    string x = "test1";
    switch(x){
    case "test1" : break;
    case "test2" : break;
    default : break;
    }
    Why this don't work for string?

  2. #2
    Join Date
    Jun 2007
    Location
    United States
    Posts
    275

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

    you cant use switch with string, however you could write your own switch if you really wanted to

    from google: http://www.codeguru.com/Cpp/Cpp/cpp_...icle.php/c4067
    Last edited by bovinedragon; February 19th, 2008 at 07:10 PM.
    Don't forget to rate my post if I was helpful!

    Use code tags when posting code!
    [code] "your code here" [/code]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured