Thread: Compiling errors again

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    14

    Question Compiling errors again

    What is wrong withthis here is the error and the code?

    hw6.cpp: In function `void getinfo(int &, double &, double &, char &, char &
    )':
    hw6.cpp:40: parse error before `else'
    line 40 has an * to identify it

    [code]

    if (day = M && day2 == O || day == T && day2 == U || day == W && day2 =\
    = E || day == T && day2 == H || day == F && day2 == R);
    if (time >= 1 && time < 13 );

    cout << coste;
    * else if ((time =< 18:00) || (time => 8:00));
    cout << costd;
    Jessica

  2. #2
    Registered User Strider's Avatar
    Join Date
    Aug 2001
    Posts
    149
    if statements should not be concluded with a semi-colon. Remove the semi-colons and try again.

    David
    One Ring to rule them all, One Ring to find them,
    One Ring to bring them all and in the darkness bind them
    In the Land of Mordor where the Shadows lie.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    Code:
    if ((day == M && day2 == O )|| 
         (day == T && day2 == U)|| 
         (day == W && day2 == E)|| 
         (day == T && day2 == H) || 
          (day == F && day2 == R)
        ) 
    {
       if (time >= 1 && time < 13 ) 
           cout << coste; 
       else if (time =< 18:00 || time => 8:00) 
           cout << costd;
    }
    ==========================
    When using complex conditionals make them easier to read by placing them in columar form.

    I suspect you want to check each day individually in the conditional and proceed only if one of the options is true. Therefore use the interior () to create appropriate precedence evaluation.

    Drop the semicolons after the if statement conditionals, they don't belong there, and are the most likely cause for the error statements.
    Last edited by elad; 04-04-2002 at 10:17 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  2. Replies: 4
    Last Post: 03-10-2008, 07:03 AM
  3. Quincy 2005: Compiling Errors
    By Thileepan_Bala in forum C Programming
    Replies: 6
    Last Post: 01-18-2008, 08:26 PM
  4. Replies: 2
    Last Post: 12-07-2004, 02:31 AM
  5. errors in my class....
    By o0obruceleeo0o in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2003, 03:22 AM