gpt4 book ai didi

c++ - 不能在 C++ 中使用我的对象 push_front() 标准库列表

转载 作者:太空宇宙 更新时间:2023-11-04 14:51:52 25 4
gpt4 key购买 nike

我有一个类,我想使用标准库列表来存储它们的列表。我基本上想要 push_front() 列表。所以我的代码是这样的:

#include <list>
/* ... lots of stuff ...*/

complexNode myObject();

std::list<complexNode> complexList();

myList.push_front(myObject);

但是编译器抛出这个错误:

错误:请求'complexList'中的成员'push_front',它是非类类型'std::list > ()()'

类 complexNode 有一个复制构造函数。

我真的不明白这个问题以及该错误的实际含义...请帮忙!

最佳答案

std::list<complexNode> complexList();

这不应该是:

std::list<complexNode> complexList; // without the () 

关于c++ - 不能在 C++ 中使用我的对象 push_front() 标准库列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/890958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com