Im trying to create a vector that will hold pointers to other pointers to unsigned chars. my vector definition is as follows
std::vector<unsigned char**> slices; // data for each slice, in order
//populating vector
unsigned char a = 1;
for (int k = 0; k < size; k++)
{
unsigned char ** tempSlice = new unsigned char*;
slices.push_back(tempSlice);
for (int y = 0; y < height; y++)
{
unsigned char * tempY = new unsigned char;
slices[k].push_back(&tempY);
for (int x = 0; x < width; x++)
{
slices[k][y][x] = a;
}
}
}
the error i get however is something allong the lines of:
error request for member ‘push_back’ in ‘((VolImage*)this)-
>VolImage::slices.std::vector<_Tp, _Alloc>::operator[]<unsigned char**,
std::allocator<unsigned char**> >(((std::vector<unsigned
char**>::size_type)k))’, which is of non-class type
‘__gnu_cxx::__alloc_traits<std::allocator<unsigned char**> >::value_type
{aka unsigned
I dont know what im doing wrong. Also, if anyone could have a look at my destructor method to see if im on the right track:
VolImage::~VolImage()
{
std::cout<<"Destructor"<<std::endl;
//deconstructing the vector of slices
int size = slices.size();
for (int k = 0; k < size; k++)
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
delete &slices[k][y][x];
}
delete[] slices[k][y];
}
delete[] slices[k];
}
delete[] &slices;
}