没有可行的重载+ =?

时间:2014-09-27 02:43:49

标签: c++ vector overloading

有人可以告诉我为什么我收到这个“没有可行的超载”?我很困惑为什么我收到这个....我是一个菜鸟。

int main()
{
char ch;
    vector<int> temp;

    ifstream infile;
    infile.open("tempsF.txt");

    if (infile.fail())
    {
        cout << "Could not open file numbers." << "\n";
        return 1;
    }
    int data;
    infile >> data;
    while (!infile.eof())
    {
        if(isalpha(ch) || ispunct(ch))
        {
            if(isupper(ch) && ch != '\n')

                temp += " ";<<<<<<<<<<<<<<<<<<<<<<<<< No Viable Overloaded '+='

                temp += ch;<<<<<<<<<<<<<<<<<<<<<<<<<< No Viable Overloaded '+='
        }
    }

1 个答案:

答案 0 :(得分:7)

那是你如何使用std::vector<int>。尝试更像:

temp.push_back(42);

或者你想要一个std::vector<std::string>然后你可以:

temp.push_back(" ");

operator +=()没有为std::vector定义。

相关问题