Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从迭代器中获取索引值。但我不断收到错误“间接需要指针操作数('long'无效)”知道吗?我需要获取索引。在以下示例中,它应该输出 2。
template<typename T> void practice(T begin, T end) { T it = begin; it++; it++; auto index = it - begin; cout << *index;
cout << index;
不需要*取消引用。
*