Thread: Unresloved Externals.....

  1. #1
    DonkeyKong
    Guest

    Angry Unresloved Externals.....

    is there trulyanything else in the world more evil?

    you code for hours to find out YES! it compiles then, like a ton of bricks it hits you........unresolved eternals....


    ARRGHHHHHHH

    ok now that thats out

    here is my code. it is in 3 linked source files


    here is the header followed by the class definition, then the actual
    program itself. any help is greatly appreciated.


    Code:
    #ifndef BUB_H
    #define BUB_H
    
    class sort
    {
    public:
    sort();
    ~sort();
    void bubble( int [], const int, bool (*)( int, int ) );
    void swap(int * const, int * const);
    
    
    };
    
    
    
    
    #endif
    
    // now the function list
    
    #include <iostream>
    using namespace std;
    
    #include "BUB.H"
    
    
    sort::sort()
    {}
    
    sort::~sort()
    {}
    void sort::bubble( int work[], const int size, 
                 bool (*compare)( int, int ) )
    {
       void swap( int * const, int * const );   
    
       for ( int pass = 1; pass < size; pass++ )
    
          for ( int count = 0; count < size - 1; count++ )
    
             if ( (*compare)( work[ count ], work[ count + 1 ] ) )
                swap( &work[ count ], &work[ count + 1 ] );
    }
    
    
    
     void sort::swap(int * const element1Ptr, int * const element2Ptr )
    {
       int temp;
    
       temp = *element1Ptr;
       *element1Ptr = *element2Ptr;
       *element2Ptr = temp;
    }
    
    
    bool ascending( int a, int b )
    {
       return b < a;   
    }
    
    bool descending( int a, int b )
    {
       return b > a;   
    }
    
    // and the actual running program
    
    #include <iostream>
    using namespace std;
    
    #include <iomanip>
    
    using std::setw;
    
    #include "BUB.H"
    
    bool ascending( int, int );
    bool descending( int, int );
    
    int main()
    {
       
       sort b;
       
    	
    	
       const int arraySize = 10;
       int order, 
           counter,
           a[ arraySize ] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37 };
    
       cout << "Enter 1 to sort in ascending order,\n" 
            << "Enter 2 to sort in descending order: ";
       cin >> order;
       cout << "\nData items in original order\n";
       
       for ( counter = 0; counter < arraySize; counter++ )
          cout << setw( 4 ) << a[ counter ];
    
       if ( order == 1 ) {
         b.bubble( a, arraySize, ascending);
          cout << "\nData items in ascending order\n";
       }
       else {
          b.bubble( a, arraySize, descending);
          cout << "\nData items in descending order\n";
       }
    
       for ( counter = 0; counter < arraySize; counter++ )
          cout << setw( 4 ) << a[ counter ];
    
       cout << endl;
       
       
    
    
    
    return 0;
    
    
    }

  2. #2
    What externals are unresolved? A copy of the error messages would be extremly helpful in determining your problem.
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  3. #3
    Donkeykong
    Guest

    OOPS!!! :)

    geez sorry here she is


    [CODE]

    --------------------Configuration: bub - Win32 Debug--------------------
    Linking...
    bubM.obj : error LNK2001: unresolved external symbol "void __cdecl swap(int * const,int * const)" (?swap@@YAXQAH0@Z)
    Debug/bub.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    bub.exe - 2 error(s), 0 warning(s)
    [\CODE]

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    272
    Why have you re-declared swap from within your bubble method? Your linker looks like it's looking for a global swap function, instead of the member function.
    Joe

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. unresolved externals??
    By pokiepo in forum C Programming
    Replies: 6
    Last Post: 07-02-2008, 11:38 AM
  2. Template class and unresolved externals..!
    By Halloko in forum C++ Programming
    Replies: 16
    Last Post: 07-12-2005, 06:28 PM
  3. Unresolved Externals
    By nickname_changed in forum C++ Programming
    Replies: 10
    Last Post: 08-31-2003, 06:13 PM
  4. unresolved externals
    By Shadow12345 in forum C++ Programming
    Replies: 1
    Last Post: 05-07-2002, 03:15 PM
  5. Help wanted for unresolved externals
    By D@nnus in forum C Programming
    Replies: 1
    Last Post: 11-19-2001, 02:31 PM