Thread: cannot call another function error

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    91

    cannot call another function error

    i get error
    Code:
    sexy.cpp: In member function `void sexy::setOutput(sexyt::Type,
       bool)':
    sexy.cpp:19: error: no matching function for call to `search(
       sexyt::Type&)'
    for this code
    this is sexy.cpp
    Code:
    #include "mate.h"
    void sexy::kiss(sexyt::Type t, bool status) {
            if(status)
            {
                    search(t);                                              
            }
            else
            {
    
            }
    }
    and this is mate.cpp
    Code:
    void mate::search(sexyt::Type t) {
         /*blah blah code*/
    }

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    according to your your error, it's looking for Type reference, so my guess is that your mate.h has search defined as such:
    Code:
    void mate::search(sexyt::Type & t);
    where as your definition in the cpp leaves out the reference. That's the first thing I would check to fix this problem. There could be some other things, but that's top of the list.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    91
    i have defined it as
    Code:
    void mate::search(sexyt::Type t);

  4. #4
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    do both mate and sexy have access to Type? Meaning, is Type declared in the public field of sexyt?

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    91
    ok this is what i have
    Code:
    class mate {
     public:
            void search(sexyt::Type t);
     private:
            class Node {
                    public :
                            Node* nextPtr;
                            sexyt::Type t;
            };
    and in the mate class
    i have
    #include "mate.h"

  6. #6
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I'm assuming you have included sexyt.h in your mate.h file. If not, that would be a problem. It might not like the fact that you have a data member named t, and a formal parameter of the search function named t.

    I also just noticed that it's not ........ed off about your kiss function, it doesnt like setOutput where ever that may be....so we've been barking up the wrong tree.

  7. #7
    Registered User
    Join Date
    Jul 2004
    Posts
    91
    hrm i changed the name of hte function to searchLL and i got a different error..
    Code:
    /*mate.h*/
    
     public:
            void searchLL(M::Type ty);
    
     private:
            class Node {
                    public :
                            M::Type t;
            };
            int count;
    };
    
    /* mate.cpp */
    void mate::searchLL(M::Type ty) {
    
    }
    
    
    
    /*sexy.cpp*/
    #include "mate.h"
    
    void sexy::setOutput(M::Type ty, bool status) {
            if(status)
            {
                    searchLL(ty);                                             
            }
            else
            {
    
            }
    }
    getting the error
    Code:
    mate.cpp: In member function `void mate::setOutput(M::Type,
       bool)':
    mate.cpp:20:  error: `searchLL' undeclared (first use this function)
    mate.cpp:20: error: (Each undeclared identifier is reported only once for
       each function it appears in.)
    Last edited by paperbox005; 08-02-2004 at 06:45 AM.

  8. #8
    Registered User
    Join Date
    Jul 2004
    Posts
    101
    searchLL is a member function of mate. sexy::setOutput cannot see searchLL because it is not declared in the global namespace, so the compiler correctly assumes that it does not exist.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM