error: undefined reference

This is a discussion on error: undefined reference within the C++ Programming forums, part of the General Programming Boards category; Not sure what I'm doing wrong. Here is the error message: main.cpp:32: undefined reference to `FindPath::FindPath(Graph&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)' ...

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    15

    error: undefined reference

    Not sure what I'm doing wrong. Here is the error message:
    main.cpp:32: undefined reference to `FindPath::FindPath(Graph&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'

    And here is my code:

    Code:
    int main(int argc, char** argv) {
        string userInput = "Tom Hanks";
        string temp = "huh?";
        stack<string> myStack;
        Graph myGraph(temp);
        
        //cin>>userInput;
        
        FindPath myPath(myGraph, userInput);
        myPath.pathTo(userInput, myStack);
        
        
        cout<<"Distance: "<<myPath.distanceTo(userInput)<<endl;
    
        return 0;
    The error occurs at all three lines that call myPath.

  2. #2
    Registered User
    Join Date
    Apr 2012
    Posts
    15
    Never mind, fixed it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. undefined reference error, please help me
    By leo2008 in forum C Programming
    Replies: 8
    Last Post: 03-27-2012, 03:50 AM
  2. gcc error, undefined reference
    By drshmoo in forum C Programming
    Replies: 2
    Last Post: 04-04-2011, 09:33 PM
  3. Undefined reference error
    By pshirishreddy in forum C Programming
    Replies: 11
    Last Post: 08-02-2009, 06:34 PM
  4. Undefined Reference Error
    By NuNn in forum C Programming
    Replies: 12
    Last Post: 01-15-2009, 12:34 PM
  5. undefined reference error
    By gcctest in forum C Programming
    Replies: 3
    Last Post: 12-19-2008, 07:17 AM

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