In header file, I declared the following as a public member variable:
vector< vector<unsigned char> > arImage;
In source code, I define temp
vector<vector<unsigned char> > temp (numImage, vector<unsigned char>(sizeImage));
Now I try to ,
temp.swap(arImage);
But an error occured. (detail errors are omitted because they are not English)
with
[
_Ty=std::vector<unsigned char>
]
////////////
Addition,,,,,,,,
I want to swap
vector<vector<unsigned char> > to vector<vector<unsigned char> >
I’m working with MFC. I can’t find proper method, so I actually take another approach.
In header file,
vector< vector<unsigned char> > * arImage;
In source code,
arImage = new vector< vector<unsigned char> > (numImage, vector<unsigned char>(sizeImage));
But this approach is not comfortable.(this approach is no error)
I want to use arImage[i][j].
In this approach, I have to use (*arImage)[i][j]
The thing you are doing wrong here is you are trying to swap
vector< unsigned char >with vector ofvector< unsigned char >which is not possible.Vector arImagehas items of typeunsigned charwhile temp type isvector<vector<unsigned char> >so temp items arevector<unsigned char>.So it make sense as can not swap
vector<unsigned char>withunsigned char. Similarly you can not swapvector< unsigned char >withvector <vector< unsigned char >>.I hope it explains everything.