简体   繁体   中英

multidimensional vector string

Hello i am trying to make a wrapper for handling rows and columns results from a MySQL query. The return data from an statement can be an string or NULL pointer. So here is my attempt:

class RowWrapper {
public:
    std::vector< std::vector <std::string> > data;
    void SetVector(unsigned int rows, unsigned int columns);
};

void RowWrapper::SetVector(unsigned int rows, unsigned int columns)
{
    for (int x = 0; x > rows; x++)
    {
        std::vector<std::string> p_rows;
        for (int y = 0; y > columns; y++)
        {
            p_rows.push_back(x*y); //Error here
        }
        data.push_back(temp_rows);
    }
}

The error i have is there is no instance for overloaded function, probably missing something about vectors or strings.

Your loop goes for as long as x > rows? And then you are incrementing? I think this might run for ever...or for as long as you don't pass the maximal int value

Also, your push_back takes an int as argument and there is no constructor for string that takes an int value as argument. The overloaded function error might result from that?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM