Thread: If statement trouble??!

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    21

    If statement trouble??!

    //Here is my code for part of my program, I am getting a error message of:
    c:\documents and settings\carrie\desktop\stackclass.cpp(31) : error C2440: '=' : cannot convert from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'double'



    if (parkinglot.LookAtTop() != s.substr(1)){
    counter ++;
    alley.Push(parkinglot.LookAtTop());

    parkinglot.Pop();
    parkinglot.LookAtTop();
    };
    if (parkinglot.LookAtTop() == plate){//This is where the arrow points at
    cout << counter << "car(s) moved to get out" <<endl;
    };
    };

    Any Suggestions??? I think it has to do with Push being a double function and Push being a void...or I may be totally off??!!


  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    The error said that the code tried to compare a string object to a double primitive data type.

    What data type is plate and what data type is stored in the stack?

    Kuphryn

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    21
    The stack is storing strings---(license plate#'s)

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by riley03
    The stack is storing strings---(license plate#'s)
    then its probably teeling you that the "plate" variable in

    Code:
    if (parkinglot.LookAtTop() == plate)
    is a double....NOT a string

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Usefulness of the "else if" statement
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 05:19 AM
  2. Switch statement
    By beene in forum C++ Programming
    Replies: 21
    Last Post: 07-01-2007, 08:13 AM
  3. If statement being ignored?
    By FincH in forum C Programming
    Replies: 3
    Last Post: 04-18-2007, 01:51 PM
  4. having trouble understanding this statement
    By kes103 in forum C++ Programming
    Replies: 2
    Last Post: 10-03-2003, 09:00 AM
  5. string & if statement
    By Curacao in forum C++ Programming
    Replies: 4
    Last Post: 05-02-2003, 09:56 PM