Here's the basics. I'm trying to create a vector class with all the functionality of a regular vector but with 2 simple changes to accomidate refrencing it as though it were at 3D array. If there is an easier way to do this, let me know.
1: the at(int) function will be overloaded to handle at(int,int,int)
2: there will be 3 private ints to keep track of xSize, ySize, and zSize, as well as appropriate accessor and mutator functions.
Seems easy right? wrong. I've run into problems up the wazoo. Previously I had implemented the functions in a .cpp file, but that caused memory errors. In it's current form, it doesn't crash, but when I create a new Vector3d, it complains whenever I try and use a function that SHOULD be inhereted from std::vector. Am I just declaring this wrong or what? Help!!!
FILE:Vector3d.h
#include <vector>
using namespace std;
template <class T>
class Vector3d : public std::vector<T> {
public:
Vector3d();
Vector3d(int xSize, int ySize, int zSize);
T at(int x, int y, int z){
return this->vector<T>::at( (x) + (y*myXsize) + (z*myXsize*myYsize) );
};
void setDimensions(int xSize, int ySize, int zSize){
if(this->capacity() < xSize*ySize*zSize){
this->resize(xSize*ySize*zSize);
}
myXsize = xSize;
myYsize = ySize;
myZsize = zSize;
}
void setDimensions(int cubeSize){
if(this->capacity() < cubeSize^3){
this->resize(cubeSize^3);
}
myXsize = cubeSize;
myYsize = cubeSize;
myZsize = cubeSize;
}
//Accessor
int xSize(void){ return myXsize; }
int ySize(void){ return myYsize; }
int zSize(void){ return myZsize; }
private:
int myXsize;
int myYsize;
int myZsize;
};