【发布时间】:2019-08-08 08:25:48
【问题描述】:
我正在为一个项目处理向量指针,但我无法打印向量中的所有元素。我尝试过运算符重载,但它不正确:
vector<list<int*>*> *v = new vector<list<int*>*> {
new list<int*> {new int(2), new int (7)},
new list<int*> {new int(2), new int (7)}
};
for (int i = 0; i < v->size(); i++) {
auto a = v[i].begin();
while (a != v[i].end()) {
cout << **a;
a++;
}
}
【问题讨论】:
-
欢迎来到 StackOverflow。请不要发布代码图像,而是将实际代码添加到问题中。另外花一些时间阅读How to Ask,然后编辑您的问题以澄清您的问题。
-
天哪,为什么会有这么多指针
标签: c++ pointers vector operator-overloading