Valhalla Legends Forums Archive | C/C++ Programming | Problem with Vector Syntax [Fixed]

AuthorMessageTime
Dyndrilliac
Sorry, I fixed my problem already. I forgot to include the '()' after the vector 'size' method.
November 11, 2005, 9:36 PM
Arta
Please don't erase your posts - the information could have helped others.
November 12, 2005, 2:20 PM
Dyndrilliac
Well, the problem I was having was with this code:[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;
            }
        }
    }
}[/code]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)[/quote]And I then realized that I had forgotten to add the '()' after the Vector's 'size' method.
November 13, 2005, 5:28 PM

Search