• Welcome to Valhalla Legends Archive.
 

Problem with Vector Syntax [Fixed]

Started by Dyndrilliac, November 11, 2005, 03:36 PM

Previous topic - Next topic

Dyndrilliac

Sorry, I fixed my problem already. I forgot to include the '()' after the vector 'size' method.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

Arta

Please don't erase your posts - the information could have helped others.

Dyndrilliac

Well, the problem I was having was with this code:void BubbleSort(vector<double> &NumVector) {
    double dfTemp = 0;

    for (int x = 0; x < NumVector.size; x++) {
        for (int y = x + 1; y < NumVector.size; y++) {
            if (NumVector[y] < NumVector[x]) {
                dfTemp = NumVector[y];
                NumVector[y] = NumVector[x];
                NumVector[x] = dfTemp;
            }
        }
    }
}
I had gotten the following error:
Quote--------------------Configuration: SortingIntegers - Win32 Debug--------------------
Compiling...
SortingAlgorithms.cpp
C:\Documents and Settings\Matt\My Documents\Source Code\C++\Personal Projects\SortingIntegers\SortingAlgorithms.cpp(52) : error C2297: '<' : illegal, right operand has type 'unsigned int (__thiscall std::vector<double,class std::__default_alloc_temp
late<0,0> >::*)(void) const'
C:\Documents and Settings\Matt\My Documents\Source Code\C++\Personal Projects\SortingIntegers\SortingAlgorithms.cpp(53) : error C2297: '<' : illegal, right operand has type 'unsigned int (__thiscall std::vector<double,class std::__default_alloc_temp
late<0,0> >::*)(void) const'
Error executing cl.exe.

SortingAlgorithms.obj - 2 error(s), 0 warning(s)
And I then realized that I had forgotten to add the '()' after the Vector's 'size' method.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.