0
#include <iostream>
#include <vector>
using namespace std;
struct a_struct { int an_int; };
int main()
{
vector <vector <a_struct> > the_vec;
vector <a_struct> * p_vs;
p_vs = & the_vec[0];
*(p_vs)[0].an_int=0; //error: 'class __gnu_debug_def::vector<a_struct,
//std::allocator<a_struct> >' has no member named 'an_int'
}
我弄不明白为什么我会收到上述编译错误。尝试使用指向结构向量的指针访问结构类型的错误
错误消息告诉你'*(p_vs)[0]'具有类型'vector'。 –
@射线那不应该是这样。代码如何实现? –
我在下面给出了答案。这是因为优先。 –