文字列のベクトルのベクトルの最後に文字列を追加しようとしていたところ、どういうわけかメモリの問題が発生しました。
私のコードはこれに似たものです
vector<vector<string>> slist;
....
slist.push_back(vector1);
slist.push_back(vector2);
...
for(int i=0; i<10; i++){
int length = slist.size()-1;
slist[length].push_back("String"); // also tried slist.back().push_back("S");
}
そして、これはどのように私にメモリの問題を引き起こしますか
Invalid read of size 8
==2570== at 0x404D18: std::vector<std::string, std::allocator<std::string> >::push_back(std::string const&) (stl_vector.h:735)
==2570== by 0x403956: main (asm.cc:400)
==2570== Address 0xfffffffffffffff0 is not stack'd, malloc'd or (recently) free'd
==2570==
==2570==
==2570== Process terminating with default action of signal 11 (SIGSEGV)
==2570== Access not within mapped region at address 0xFFFFFFFFFFFFFFF0
==2570== at 0x404D18: std::vector<std::string, std::allocator<std::string> >::push_back(std::string const&) (stl_vector.h:735)
==2570== by 0x403956: main (asm.cc:400)
==2570==
誰でも理由を教えてもらえますか??
PS: 前回のよくない質問について申し訳ありません..