ベクトルポインタ要素にアクセスする必要があります。アニメーション構造用に次のコードがあります(ここでは簡略化されており、不要な変数は切り捨てられています)。
struct framestruct {
int w,h;
};
struct animstruct {
vector<framestruct> *frames;
};
vector<framestruct> some_animation; // this will be initialized with some frames data elsewhere.
animstruct test; // in this struct we save the pointer to those frames.
void init_anim(){
test.frames = (vector<framestruct> *)&some_animation; // take pointer.
}
void test_anim(){
test.frames[0].w; // error C2039: 'w' : is not a member of 'std::vector<_Ty>'
}
アレイは機能します。テストしました
test.frames->size()
。計画どおり7でした。
では、ベクトルからN番目のインデックスにあるベクトル要素(wとh)にアクセスするにはどうすればよいですか?