Functions in a switch case...

This is a discussion on Functions in a switch case... within the C++ Programming forums, part of the General Programming Boards category; Why is it this doesn't work? Code: int func() { return 1; } //... switch (input) { case func(): //... ...

  1. #1
    Not stupid, just stupider yaya's Avatar
    Join Date
    May 2007
    Location
    Earthland
    Posts
    204

    Thumbs up Functions in a switch case...

    Why is it this doesn't work?

    Code:
    int func()
    {
          return 1;
    }
    
    //...
    
          switch (input)
          {
                case func():
                      //...
                      break;
          }
    Thanks in advanced!

  2. #2
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Because this is wrong !
    case takes only some constants (int,char)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 03-05-2009, 10:32 AM
  2. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. switch case statement
    By stanlvw in forum C++ Programming
    Replies: 3
    Last Post: 02-26-2008, 04:06 AM
  5. Intel syntax on MinGW ?
    By TmX in forum Tech Board
    Replies: 2
    Last Post: 01-06-2007, 08:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21