Thread: Error: Invalid Conversion `bool' to `list_node*'

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    15

    Error: Invalid Conversion `bool' to `list_node*'

    main.cpp:83: error: invalid conversion from `bool' to `list_node*'
    main.cpp:83: error: initializing argument 1 of `void write_list(list_node*)'

    I can't seem to fix this error

    Code:
         // equal
         cout << "Enter two lists for equal: ";
         p = read_list();
         q = read_list();
         write_list( equal(p, q) );

    Code:
    bool equal(list p, list q)
       {
       if (is_null(p) && is_null(q)) return true;
       if (is_null(p) || is_null(q)) return false;
       if (atom(car(p)) != atom(car(q))) return false;
       if (atom(car(p)))
       return eq(car(p), car(q)) && equal(cdr(p), cdr(q));
       return (equal(car(p), car(q)) && equal(cdr(p), cdr(q)));
       }

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Code:
    write_list( equal(p, q) );
    write_list() probably expects a 'list_node*', and you're passing it a bool (since that's what equal returns).
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 11:31 PM
  4. Do I have a scanf problem?
    By AQWst in forum C Programming
    Replies: 2
    Last Post: 11-26-2004, 06:18 PM
  5. Creation of Menu problem
    By AQWst in forum C Programming
    Replies: 8
    Last Post: 11-24-2004, 09:44 PM