【发布时间】:2020-07-02 19:49:44
【问题描述】:
我正在尝试将以下代码用于我的节点编辑器,我正在使用 Visual Studio 2019,每当我尝试插入节点对象时都会出错
编辑:忘了 push_back 是正确的函数,我的错
std::vector<Node*> nodes;
void Example(){
Node* s = new Node();
nodes.insert(s);
}
完整的错误:
no instance of overloaded function "std::vector<_Ty, _Alloc>::insert
[with _Ty=Node *, _Alloc=std::allocator<Node *>]" matches the argument list
【问题讨论】:
-
A decent
std::vector<T>::insertreference 在这里会很有帮助。也许some decent books 也会有帮助? -
你能解释一下你想用一个参数调用en.cppreference.com/w/cpp/container/vector/insert的哪个重载吗?我没有看到只接受一个参数的重载。
-
请发帖minimal reproducible example。此问题中没有足够的详细信息/信息来提供答案。
-
vector的insert方法都带有多个参数,通常是要添加的项和要添加项的位置。也许您正在寻找push_back。 -
@Someprogrammerdude 必须需要更多的咖啡。语法高亮让我觉得它是在调用参数“列表”,而不是“参数列表”。
标签: c++ vector visual-c++ compiler-errors