What is Error 1 error LNK2019: unresolved external symbol ????

Discussion in 'C++' started by Trent, Jun 29, 2007.

  1. Trent

    Trent Guest

    Here is the error while using Visual Studio 2005

    Error 1 error LNK2019: unresolved external symbol "void __cdecl
    print(int,int,int,int,int,int,int,int)" (?print@@YAXHHHHHHHH@Z) referenced
    in function _main assign2.obj

    Thanks a lot !


    Here is the code:

    #include <iostream>
    #include <fstream>
    #include<iomanip>

    using namespace std;

    void bubbleSort(int *array, const int, int &); //function prototypes

    void selectionSort(int *, const int, int &);

    void insertionSort(int *, const int, int &);

    void swap(int *, int *);

    void print(int array, int size, int bubbleSort, int selectionSort, int
    insertionSort, int bcount, int scount, int icount);

    // print(&numArray, arraySize, &bsort, &ssort, &isort,
    bsortCounter,sSortCounter, iSortCounter);

    ifstream inFile;

    ofstream outFile;

    int main()

    {

    const int arraySize = 10;

    int numArray[arraySize];

    int bsort[arraySize];

    int bsortCounter =0;

    int isort[arraySize];

    int iSortCounter =0;

    int ssort[arraySize];

    int sSortCounter =0;

    // each sort needs array and counter



    inFile.open("input.txt"); //opening input file

    if (!inFile)

    {

    cerr << "Error Opening File" << endl;

    system("pause");

    return -1;

    }


    for (int i =0;i < 5;i++)

    {

    for (int j=0; j< arraySize;j++)

    {

    inFile >> numArray[j];

    bsort[j]=numArray[j];

    isort[j]=numArray[j];

    ssort[j]=numArray[j];

    }

    cout << endl;

    bubbleSort(bsort, arraySize, bsortCounter);// call the sort functions

    selectionSort(ssort, arraySize,sSortCounter);

    insertionSort(isort, arraySize,iSortCounter);


    }

    print(*numArray, arraySize, *bsort, *ssort, *isort,
    bsortCounter,sSortCounter, iSortCounter);

    cout << endl;


    system("pause");

    inFile.close();// close files

    outFile.close();

    return 0;

    }









    // Funtions below







    void bubbleSort(int *array, const int size, int &count)

    {

    int i, pass;

    for (pass =0; pass < size - 1; pass++) //# of passes

    count= count+1;

    for (i= 0; i < size - 1; i++) // one pass

    if (array > array[i+1]) //one comparison

    {

    swap(&array, &array[i+1]);


    }

    }// end of bubble Sort function



    void selectionSort(int *array, const int size, int &count)

    {

    int i, j, tmp;

    for (i = 0; i < size - 1; i++)

    {

    tmp = i;

    count = count + 1;

    for (j = i+1; j < size; j++)

    if (array[j] < array[tmp])

    tmp = j;

    swap(&array, &array[tmp]); //call swap funtion

    }

    }

    void swap(int *element1, int *element2)

    {

    int tmp = *element1;

    *element1 = *element2;

    *element2 = tmp;

    }



    void insertionSort(int *array,const int size, int &count)

    {

    int tmp,i;

    for(int j=1;j<size;j++)

    {

    tmp=array[j];

    i=j-1;

    while(array>tmp && i>=0)

    {

    count = count +1;

    array[i+1]=array;

    i--;

    }

    array[i+1]=tmp;

    }

    }


    void print(int *array, int size, int *bubbleSort, int *selectionSort, int
    *insertionSort, int bcount, int scount, int icount)

    {

    cout << " Unsorted List Bubble Sorted Selection Sorted Insertion Sorted" <<
    endl;

    for (int k =0;k < size;k++)

    cout << setw(15) <<array[k] << setw(16) << bubbleSort[k] << setw(20) <<
    selectionSort[k] << setw(19) << insertionSort[k] << endl;

    cout << endl << "Number: "<<setw(23) <<bcount << setw(20)<<scount
    <<setw(19)<< icount << endl;

    }// end of print function
    Trent, Jun 29, 2007
    #1
    1. Advertising

  2. Trent

    Guest

    On 6 29 , 11 11 , "Trent" <> wrote:
    > Here is the error while using Visual Studio 2005
    >
    > Error 1 error LNK2019: unresolved external symbol "void __cdecl
    > print(int,int,int,int,int,int,int,int)" (?print@@YAXHHHHHHHH@Z) referenced
    > in function _main assign2.obj
    >
    > Thanks a lot !


    Maybe you should change your print function declaration and print
    function call
    like this?

    > void print(int array, int size, int bubbleSort, int selectionSort, int
    > insertionSort, int bcount, int scount, int icount);


    void print(int *array, int size, int *bubbleSort, int *selectionSort,
    int
    *insertionSort, int bcount, int scount, int icount)

    and

    > print(*numArray, arraySize, *bsort, *ssort, *isort,
    > bsortCounter,sSortCounter, iSortCounter);


    print(numArray, arraySize, sort, ssort, isort,
    bsortCounter,sSortCounter, iSortCounter);

    misunderstand pointer's use?

    BestRegards
    Kmoving
    , Jun 29, 2007
    #2
    1. Advertising

  3. Trent

    Trent Guest

    <> wrote in message
    news:...
    > On 6 29 , 11 11 , "Trent" <> wrote:
    >> Here is the error while using Visual Studio 2005
    >>
    >> Error 1 error LNK2019: unresolved external symbol "void __cdecl
    >> print(int,int,int,int,int,int,int,int)" (?print@@YAXHHHHHHHH@Z)
    >> referenced
    >> in function _main assign2.obj
    >>
    >> Thanks a lot !

    >
    > Maybe you should change your print function declaration and print
    > function call
    > like this?
    >
    >> void print(int array, int size, int bubbleSort, int selectionSort, int
    >> insertionSort, int bcount, int scount, int icount);

    >
    > void print(int *array, int size, int *bubbleSort, int *selectionSort,
    > int
    > *insertionSort, int bcount, int scount, int icount)
    >
    > and
    >
    >> print(*numArray, arraySize, *bsort, *ssort, *isort,
    >> bsortCounter,sSortCounter, iSortCounter);

    >
    > print(numArray, arraySize, sort, ssort, isort,
    > bsortCounter,sSortCounter, iSortCounter);
    >
    > misunderstand pointer's use?
    >


    Doh!

    My bad..I see the problem..thanks for the great help.
    It compiles now.

    > BestRegards
    > Kmoving
    >
    >
    Trent, Jun 29, 2007
    #3
  4. Trent

    Trent Guest

    <> wrote in message
    news:...
    > On 6 29 , 11 11 , "Trent" <> wrote:
    >> Here is the error while using Visual Studio 2005
    >>




    While it compiles, it no longer is sorting properly.
    I had the code for printing out the results in main();

    I now put the print out in the function and now the arrays are not being
    sorted.


    >> Error 1 error LNK2019: unresolved external symbol "void __cdecl
    >> print(int,int,int,int,int,int,int,int)" (?print@@YAXHHHHHHHH@Z)
    >> referenced
    >> in function _main assign2.obj
    >>
    >> Thanks a lot !

    >
    > Maybe you should change your print function declaration and print
    > function call
    > like this?
    >
    >> void print(int array, int size, int bubbleSort, int selectionSort, int
    >> insertionSort, int bcount, int scount, int icount);

    >
    > void print(int *array, int size, int *bubbleSort, int *selectionSort,
    > int
    > *insertionSort, int bcount, int scount, int icount)
    >
    > and
    >
    >> print(*numArray, arraySize, *bsort, *ssort, *isort,
    >> bsortCounter,sSortCounter, iSortCounter);

    >
    > print(numArray, arraySize, sort, ssort, isort,
    > bsortCounter,sSortCounter, iSortCounter);
    >
    > misunderstand pointer's use?
    >
    > BestRegards
    > Kmoving
    >
    >
    Trent, Jun 29, 2007
    #4
  5. Trent

    Trent Guest

    <> wrote in message
    news:...
    > On 6 29 , 11 11 , "Trent" <> wrote:
    >> Here is the error while using Visual Studio 2005
    >>



    And finally,,

    Does not compile under g++ or gcc

    assign2.cpp:146: error: missing terminating " character
    assign2.cpp:147: error: missing terminating " character
    assign2.cpp:20: error: expected constructor, destructor, or type conversion
    before â,â token
    assign2.cpp:20: error: expected constructor, destructor, or type conversion
    before â,â token
    assign2.cpp:20: error: expected constructor, destructor, or type conversion
    before â)â token
    assign2.cpp: In function âint main()â:
    assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    assign2.cpp:66: error: initializing argument 1 of âvoid print(int*, int,
    int*, int*, int*, int, int, int)â
    assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    assign2.cpp:66: error: initializing argument 3 of âvoid print(int*, int,
    int*, int*, int*, int, int, int)â
    assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    assign2.cpp:66: error: initializing argument 4 of âvoid print(int*, int,
    int*, int*, int*, int, int, int)â
    assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    assign2.cpp:66: error: initializing argument 5 of âvoid print(int*, int,
    int*, int*, int*, int, int, int)â
    assign2.cpp: At global scope:
    assign2.cpp:143: error: expected constructor, destructor, or type conversion
    before âvoidâ



    Seems like maybe I better switch to int xxxx[]


    >> Error 1 error LNK2019: unresolved external symbol "void __cdecl
    >> print(int,int,int,int,int,int,int,int)" (?print@@YAXHHHHHHHH@Z)
    >> referenced
    >> in function _main assign2.obj
    >>
    >> Thanks a lot !

    >
    > Maybe you should change your print function declaration and print
    > function call
    > like this?
    >
    >> void print(int array, int size, int bubbleSort, int selectionSort, int
    >> insertionSort, int bcount, int scount, int icount);

    >
    > void print(int *array, int size, int *bubbleSort, int *selectionSort,
    > int
    > *insertionSort, int bcount, int scount, int icount)
    >
    > and
    >
    >> print(*numArray, arraySize, *bsort, *ssort, *isort,
    >> bsortCounter,sSortCounter, iSortCounter);

    >
    > print(numArray, arraySize, sort, ssort, isort,
    > bsortCounter,sSortCounter, iSortCounter);
    >
    > misunderstand pointer's use?
    >
    > BestRegards
    > Kmoving
    >
    >
    Trent, Jun 29, 2007
    #5
  6. Trent wrote:
    > <> wrote in message
    > news:...
    >> On 6 29 , 11 11 , "Trent" <> wrote:
    >>> Here is the error while using Visual Studio 2005
    >>>

    >
    >
    > And finally,,
    >
    > Does not compile under g++ or gcc
    >
    > assign2.cpp:146: error: missing terminating " character
    > assign2.cpp:147: error: missing terminating " character
    > assign2.cpp:20: error: expected constructor, destructor, or type conversion
    > before â,â token
    > assign2.cpp:20: error: expected constructor, destructor, or type conversion
    > before â,â token
    > assign2.cpp:20: error: expected constructor, destructor, or type conversion
    > before â)â token
    > assign2.cpp: In function âint main()â:
    > assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    > assign2.cpp:66: error: initializing argument 1 of âvoid print(int*, int,
    > int*, int*, int*, int, int, int)â
    > assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    > assign2.cpp:66: error: initializing argument 3 of âvoid print(int*, int,
    > int*, int*, int*, int, int, int)â
    > assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    > assign2.cpp:66: error: initializing argument 4 of âvoid print(int*, int,
    > int*, int*, int*, int, int, int)â
    > assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    > assign2.cpp:66: error: initializing argument 5 of âvoid print(int*, int,
    > int*, int*, int*, int, int, int)â
    > assign2.cpp: At global scope:
    > assign2.cpp:143: error: expected constructor, destructor, or type conversion
    > before âvoidâ
    >


    Show us the code. I'm not psychic.

    >
    >
    > Seems like maybe I better switch to int xxxx[]


    In a function there is no difference

    int f(int* x)

    int f(int x[])

    mean EXACTLY the same, x is a pointer to int. Confusing and stupid but true.

    john
    John Harrison, Jun 29, 2007
    #6
  7. Trent

    Trent Guest

    "John Harrison" <> wrote in message
    news:Zt1hi.10111$...
    > Trent wrote:
    >> <> wrote in message
    >> news:...
    >>> On 6 29 , 11 11 , "Trent" <> wrote:
    >>>> Here is the error while using Visual Studio 2005
    >>>>

    >>
    >>
    >> And finally,,
    >>
    >> Does not compile under g++ or gcc
    >>
    >> assign2.cpp:146: error: missing terminating " character
    >> assign2.cpp:147: error: missing terminating " character
    >> assign2.cpp:20: error: expected constructor, destructor, or type
    >> conversion before â,â token
    >> assign2.cpp:20: error: expected constructor, destructor, or type
    >> conversion before â,â token
    >> assign2.cpp:20: error: expected constructor, destructor, or type
    >> conversion before â)â token
    >> assign2.cpp: In function âint main()â:
    >> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >> assign2.cpp:66: error: initializing argument 1 of âvoid print(int*,
    >> int, int*, int*, int*, int, int, int)â
    >> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >> assign2.cpp:66: error: initializing argument 3 of âvoid print(int*,
    >> int, int*, int*, int*, int, int, int)â
    >> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >> assign2.cpp:66: error: initializing argument 4 of âvoid print(int*,
    >> int, int*, int*, int*, int, int, int)â
    >> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >> assign2.cpp:66: error: initializing argument 5 of âvoid print(int*,
    >> int, int*, int*, int*, int, int, int)â
    >> assign2.cpp: At global scope:
    >> assign2.cpp:143: error: expected constructor, destructor, or type
    >> conversion before âvoidâ
    >>

    >
    > Show us the code. I'm not psychic.




    Look in OP.

    >
    >>
    >>
    >> Seems like maybe I better switch to int xxxx[]

    >
    > In a function there is no difference
    >
    > int f(int* x)
    >
    > int f(int x[])
    >
    > mean EXACTLY the same, x is a pointer to int. Confusing and stupid but
    > true.
    >
    > john
    Trent, Jun 29, 2007
    #7
  8. Trent

    Trent Guest

    "John Harrison" <> wrote in message
    news:Zt1hi.10111$...
    > Trent wrote:
    >> <> wrote in message
    >> news:...
    >>> On 6 29 , 11 11 , "Trent" <> wrote:
    >>>> Here is the error while using Visual Studio 2005
    >>>>

    >>
    >>
    >> And finally,,
    >>
    >> Does not compile under g++ or gcc
    >>
    >> assign2.cpp:146: error: missing terminating " character
    >> assign2.cpp:147: error: missing terminating " character
    >> assign2.cpp:20: error: expected constructor, destructor, or type
    >> conversion before â,â token
    >> assign2.cpp:20: error: expected constructor, destructor, or type
    >> conversion before â,â token
    >> assign2.cpp:20: error: expected constructor, destructor, or type
    >> conversion before â)â token
    >> assign2.cpp: In function âint main()â:
    >> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >> assign2.cpp:66: error: initializing argument 1 of âvoid print(int*,
    >> int, int*, int*, int*, int, int, int)â
    >> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >> assign2.cpp:66: error: initializing argument 3 of âvoid print(int*,
    >> int, int*, int*, int*, int, int, int)â
    >> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >> assign2.cpp:66: error: initializing argument 4 of âvoid print(int*,
    >> int, int*, int*, int*, int, int, int)â
    >> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >> assign2.cpp:66: error: initializing argument 5 of âvoid print(int*,
    >> int, int*, int*, int*, int, int, int)â
    >> assign2.cpp: At global scope:
    >> assign2.cpp:143: error: expected constructor, destructor, or type
    >> conversion before âvoidâ
    >>

    >
    > Show us the code. I'm not psychic.
    >


    But here it is anyway:
    I changed it a tad bit to see if the changes would work.


    -----------------------------
    #include <iostream>
    #include <fstream>
    #include<iomanip>

    using namespace std;


    void bubbleSort(int array[], const int, int &); //function prototypes
    void selectionSort(int [], const int, int &);
    void insertionSort(int [], const int, int &);
    void swap(int *, int *);
    void print(int array[], int size, int bubbleSort[], int selectionSort[], int
    insertionSort[], int bcount, int scount, int icount);
    // print(&numArray, arraySize, &bsort, &ssort, &isort,
    bsortCounter,sSortCounter, iSortCounter);

    ifstream inFile;
    ofstream outFile;

    int main()
    {

    const int arraySize = 10;
    int numArray[arraySize];
    int bsort[arraySize];
    int bsortCounter =0;
    int isort[arraySize];
    int iSortCounter =0;
    int ssort[arraySize];
    int sSortCounter =0;
    // each sort needs array and counter (parallel arrays)


    inFile.open("input.txt"); //opening input file
    if (!inFile)
    {
    cerr << "Error Opening File" << endl;
    system("pause");
    return -1;
    }


    for (int i =0;i < 5;i++)
    {
    for (int j=0; j< arraySize;j++)
    {
    inFile >> numArray[j];
    bsort[j]=numArray[j];
    isort[j]=numArray[j];
    ssort[j]=numArray[j];
    }

    cout << endl;
    bubbleSort(bsort, arraySize, bsortCounter);// call the sort functions
    selectionSort(ssort, arraySize,sSortCounter);
    insertionSort(isort, arraySize,iSortCounter);

    print(numArray, arraySize, bsort, ssort, isort, bsortCounter,sSortCounter,
    iSortCounter);\

    }

    cout << endl;


    system("pause");

    inFile.close();// close files
    outFile.close();
    return 0;
    }





    // Funtions below




    void bubbleSort(int array[], const int size, int &count)
    {
    int i, pass;
    for (pass =0; pass < size - 1; pass++) //# of passes
    count= count+1;

    for (i= 0; i < size - 1; i++) // one pass
    if (array > array[i+1]) //one comparison
    {
    swap(&array, &array[i+1]);

    }

    }// end of bubble Sort function


    void selectionSort(int array[], const int size, int &count)
    {
    int i, j, tmp;
    for (i = 0; i < size - 1; i++)
    {
    tmp = i;
    count = count + 1;
    for (j = i+1; j < size; j++)
    if (array[j] < array[tmp])
    tmp = j;

    swap(&array, &array[tmp]); //call swap funtion
    }
    }


    void swap(int *element1, int *element2)
    {
    int tmp = *element1;
    *element1 = *element2;
    *element2 = tmp;
    }


    void insertionSort(int array[],const int size, int &count)
    {
    int tmp,i;
    for(int j=1;j<size;j++)
    {
    tmp=array[j];
    i=j-1;
    while(array>tmp && i>=0)
    {
    count = count +1;
    array[i+1]=array;
    i--;
    }
    array[i+1]=tmp;
    }
    }

    void print(int array[], int size, int bubbleSort[], int selectionSort[], int
    insertionSort[], int bcount, int scount, int icount)
    {
    cout << " Unsorted List Bubble Sorted Selection Sorted Insertion
    Sorted" << endl;

    for (int k =0;k < size;k++)
    cout << setw(15) <<array[k] << setw(16) << bubbleSort[k] << setw(20) <<
    selectionSort[k] << setw(19) << insertionSort[k] << endl;
    cout << endl << "Number: " << setw(23) <<bcount << setw(20)<<scount
    <<setw(19)<< icount << endl;

    }// end of print function
    >>
    >>
    >> Seems like maybe I better switch to int xxxx[]

    >
    > In a function there is no difference
    >
    > int f(int* x)
    >
    > int f(int x[])
    >
    > mean EXACTLY the same, x is a pointer to int. Confusing and stupid but
    > true.
    >
    > john
    Trent, Jun 29, 2007
    #8
  9. Trent wrote:
    > "John Harrison" <> wrote in message
    > news:Zt1hi.10111$...
    >> Trent wrote:
    >>> <> wrote in message
    >>> news:...
    >>>> On 6 29 , 11 11 , "Trent" <> wrote:
    >>>>> Here is the error while using Visual Studio 2005
    >>>>>
    >>>
    >>> And finally,,
    >>>
    >>> Does not compile under g++ or gcc
    >>>
    >>> assign2.cpp:146: error: missing terminating " character
    >>> assign2.cpp:147: error: missing terminating " character
    >>> assign2.cpp:20: error: expected constructor, destructor, or type
    >>> conversion before â,â token
    >>> assign2.cpp:20: error: expected constructor, destructor, or type
    >>> conversion before â,â token
    >>> assign2.cpp:20: error: expected constructor, destructor, or type
    >>> conversion before â)â token
    >>> assign2.cpp: In function âint main()â:
    >>> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >>> assign2.cpp:66: error: initializing argument 1 of âvoid print(int*,
    >>> int, int*, int*, int*, int, int, int)â
    >>> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >>> assign2.cpp:66: error: initializing argument 3 of âvoid print(int*,
    >>> int, int*, int*, int*, int, int, int)â
    >>> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >>> assign2.cpp:66: error: initializing argument 4 of âvoid print(int*,
    >>> int, int*, int*, int*, int, int, int)â
    >>> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >>> assign2.cpp:66: error: initializing argument 5 of âvoid print(int*,
    >>> int, int*, int*, int*, int, int, int)â
    >>> assign2.cpp: At global scope:
    >>> assign2.cpp:143: error: expected constructor, destructor, or type
    >>> conversion before âvoidâ
    >>>

    >> Show us the code. I'm not psychic.
    >>

    >
    > But here it is anyway:
    > I changed it a tad bit to see if the changes would work.


    Well that's the problem. I'm not prepared to try and diagnose problems
    with your code based on some old code and the changes you say you've
    made to it. Total waste of time. I'm sure all the regulars would agree
    with this.

    Anyway the code you've posted compiles fine for me under g++, so I'm not
    sure what the issue there is. Mostly likely when you got the compile
    errors under g++ with code was different from what you've just posted.

    Secondly the bubble sort code is bugged. You have missed a pair of
    braces. You have

    int i, pass;
    for (pass =0; pass < size - 1; pass++) //# of passes
    count= count+1;

    for (i= 0; i < size - 1; i++) // one pass
    if (array > array[i+1]) //one comparison
    {
    swap(&array, &array[i+1]);

    }

    it should be

    int i, pass;
    for (pass =0; pass < size - 1; pass++) //# of passes
    {
    count= count+1;

    for (i= 0; i < size - 1; i++) // one pass
    if (array > array[i+1]) //one comparison
    {
    swap(&array, &array[i+1]);

    }
    }

    Without those braces the only statement in the for loop is the 'count =
    count + 1;' statement, so you only ever do one pass.

    You should get into the habit of always indenting your code correctly.
    This isn't to make it look pretty, it precisely to catch errors like this.

    john
    John Harrison, Jun 29, 2007
    #9
  10. Trent

    Trent Guest

    "John Harrison" <> wrote in message
    news:Ovahi.10135$...
    > Trent wrote:
    >> "John Harrison" <> wrote in message
    >> news:Zt1hi.10111$...
    >>> Trent wrote:
    >>>> <> wrote in message
    >>>> news:...
    >>>>> On 6 29 , 11 11 , "Trent" <> wrote:
    >>>>>> Here is the error while using Visual Studio 2005
    >>>>>>
    >>>>
    >>>> And finally,,
    >>>>
    >>>> Does not compile under g++ or gcc
    >>>>
    >>>> assign2.cpp:146: error: missing terminating " character
    >>>> assign2.cpp:147: error: missing terminating " character
    >>>> assign2.cpp:20: error: expected constructor, destructor, or type
    >>>> conversion before â,â token
    >>>> assign2.cpp:20: error: expected constructor, destructor, or type
    >>>> conversion before â,â token
    >>>> assign2.cpp:20: error: expected constructor, destructor, or type
    >>>> conversion before â)â token
    >>>> assign2.cpp: In function âint main()â:
    >>>> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >>>> assign2.cpp:66: error: initializing argument 1 of âvoid print(int*,
    >>>> int, int*, int*, int*, int, int, int)â
    >>>> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >>>> assign2.cpp:66: error: initializing argument 3 of âvoid print(int*,
    >>>> int, int*, int*, int*, int, int, int)â
    >>>> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >>>> assign2.cpp:66: error: initializing argument 4 of âvoid print(int*,
    >>>> int, int*, int*, int*, int, int, int)â
    >>>> assign2.cpp:66: error: invalid conversion from âintâ to âint*â
    >>>> assign2.cpp:66: error: initializing argument 5 of âvoid print(int*,
    >>>> int, int*, int*, int*, int, int, int)â
    >>>> assign2.cpp: At global scope:
    >>>> assign2.cpp:143: error: expected constructor, destructor, or type
    >>>> conversion before âvoidâ
    >>>>
    >>> Show us the code. I'm not psychic.
    >>>

    >>
    >> But here it is anyway:
    >> I changed it a tad bit to see if the changes would work.

    >
    > Well that's the problem. I'm not prepared to try and diagnose problems
    > with your code based on some old code and the changes you say you've made
    > to it. Total waste of time. I'm sure all the regulars would agree with
    > this.
    >
    > Anyway the code you've posted compiles fine for me under g++, so I'm not
    > sure what the issue there is. Mostly likely when you got the compile
    > errors under g++ with code was different from what you've just posted.
    >
    > Secondly the bubble sort code is bugged. You have missed a pair of braces.
    > You have
    >
    > int i, pass;
    > for (pass =0; pass < size - 1; pass++) //# of passes
    > count= count+1;
    >
    > for (i= 0; i < size - 1; i++) // one pass
    > if (array > array[i+1]) //one comparison
    > {
    > swap(&array, &array[i+1]);
    >
    > }
    >
    > it should be
    >
    > int i, pass;
    > for (pass =0; pass < size - 1; pass++) //# of passes
    > {
    > count= count+1;
    >
    > for (i= 0; i < size - 1; i++) // one pass
    > if (array > array[i+1]) //one comparison
    > {
    > swap(&array, &array[i+1]);
    >
    > }
    > }
    >
    > Without those braces the only statement in the for loop is the 'count =
    > count + 1;' statement, so you only ever do one pass.
    >
    > You should get into the habit of always indenting your code correctly.
    > This isn't to make it look pretty, it precisely to catch errors like this.
    >



    okays a lor or the input. I guess I missed those after lack of sleep.

    Now on to try to get the swap function to work in the insertion sort.

    Trent
    > john
    Trent, Jun 29, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Allen
    Replies:
    8
    Views:
    10,904
    Scott Allen
    May 2, 2004
  2. Mastadex
    Replies:
    4
    Views:
    724
    Mastadex
    Oct 1, 2005
  3. NewsGroup
    Replies:
    3
    Views:
    653
    Michael
    Oct 27, 2006
  4. Replies:
    1
    Views:
    309
  5. Tauqir
    Replies:
    2
    Views:
    2,231
    Tauqir
    Apr 9, 2010
Loading...

Share This Page