Unresolved error in program

This is a discussion on Unresolved error in program within the C++ Programming forums, part of the General Programming Boards category; the code below has this error. main.obj : error LNK2001: unresolved external symbol "void __cdecl BubbleSort(int * const,int)" (?BubbleSort@@YAXQAHH@Z) Debug/Bubblesort2.exe ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    84

    Unresolved error in program

    the code below has this error.

    main.obj : error LNK2001: unresolved external symbol "void __cdecl BubbleSort(int * const,int)" (?BubbleSort@@YAXQAHH@Z)
    Debug/Bubblesort2.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    What have I done wrong? Please help!

    Code:
    #include<iostream>
    using namespace std;
    
    void Swap(int& num1, int& num2);
    void DisplayArray(int array[], int arraySize);
    void BubbleSort(int array[], int arraySize);
    
    int main(void)
    {
    	int ages[]={3,5,4,7};
    
    	DisplayArray(ages, (sizeof ages/sizeof ages[0]));
    	BubbleSort(ages, (sizeof ages/sizeof ages[0]));
    	DisplayArray(ages, (sizeof ages/sizeof ages[0]));
    	
    	return(0);
    }
    
    void DisplayArray(int array[], int arraySize)
    {
    	for(int i=0; i<arraySize; i++)
    	{
    		cout << array[i];
    		if(i!=arraySize-1)
    		{
    			cout << ',';
    		}
    	}
    	cout << endl;
    }
    
    void Bubblesort( int array[], int n )
    {
      for ( int i = 0; i < n-1; ++i )
        for ( int j = 1; j < n-i; ++j )
          if ( array[j-1] > array[j] )
            // Note the use here of swap()
            swap( array[j-1], array[j] );
    }
    
    
    void Swap(int &x, int &y)
    {
      int z = x;
      x = y;
      y = z;
    }

  2. #2
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Just a small typo.

    Change: void Bubblesort( int array[], int n )
    To: void BubbleSort( int array[], int n )

    Also with the Swap function.

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    84
    Monster you are a STAR!! Cheers buddy .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. unresolved external symbols...linking errors in VC++
    By rammohan2b in forum C++ Programming
    Replies: 2
    Last Post: 01-22-2009, 02:19 AM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. I need some help with my program please.
    By agentxx04 in forum C Programming
    Replies: 9
    Last Post: 09-26-2004, 08:51 AM
  4. Problem with OpenGL tutorial
    By 2Biaz in forum Windows Programming
    Replies: 18
    Last Post: 09-16-2004, 12:02 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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