C++ 错误 : No instance of overloaded function

标签 c++

我的代码不断出现同样的错误,在搜索了类似的问题之后,我仍然不知道该怎么做。在声明“building[0].push_back(Person())”的行上发生错误。

std::vector<std::vector<Person()>> addPeople(std::vector<std::vector<Person()>> building)
    {
        std::poisson_distribution<int> distribution(0);
        for (int i = 0; i < 100; i++)
        {
            int test = distribution(generator);
            if (test >= 0 && test <= 6)
            {
                if (test = 0)
                {
                    building[0].push_back(Person());
                }
                else if (test = 6)
                {
                    building[0].push_back(Person());
                }
            }
        }

        return building;
    }

最佳答案

std::vector<std::vector<Person()>> building应该是 std::vector<std::vector<Person>> building .

Person()在那个上下文中是一个什么都不做的函数,并返回 Person .

关于C++ 错误 : No instance of overloaded function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36521671/

相关文章:

c++ - 是否可以在 cpp 中检查负 0?

c++ - 错误说, "statement cannot resolve address of overloaded function"

c++ - 无法使用 vector::插入 "no instance of overloaded function..."

c++ - 如何将像素设置为 cv::Mat 对象中的值?

c++ - 开罗矩阵与 GlOrtho 矩阵等效?

c++ - 我写了一个函数来删除句子中的空格,但它只在空格前取字符而不考虑整个句子

c++ - Qt - 有没有办法获取类中所有自定义插槽和信号的列表

c++ - 如何防止输出屏幕在 Visual Studio 2013 C++ 编译器中消失

c++ - unsigned int 零的位表示

C++ 优化 : avoid a copy operation