Hello qt & c++ fans,

I have some probs overloading the [] operator of my templated grid class.
The template class looks basically like this:

Qt Code:
  1. template<class T> class Grid
  2. {
  3. public:
  4. Grid(int width, int height) : _pMat(NULL), _iWidth(0), _iHeight(0){
  5. _iWidth = width;
  6. _iHeight = height;
  7. _pMat = createGrid(width, height);
  8. }
  9.  
  10. ~Grid(void){
  11. destroyGrid();
  12. }
  13.  
  14. Matrix2Dim(const Matrix2Dim<T> &mat){//cpy...}
  15. Matrix2Dim<T>& operator=(const Matrix2Dim<T> &mat){//cpy...}
  16.  
  17. private:
  18. T** createGrid(int width, int height){
  19. T **pMat = NULL;
  20. pMat = new T *[height];
  21. pMat[0] = new T [height * width];
  22. for (int i = 0; i < height; i++)
  23. pMat[i] = &pMat[0][(i*width)];
  24. return pMat;
  25. }
  26.  
  27. void destroyGrid(void){
  28. if(_pMat != NULL){
  29. delete _pMat[0];
  30. delete[] _pMat;
  31. _pMat = NULL;
  32. _iWidth = _iHeight = 0;
  33. }
  34. }
  35. int _iWidth;
  36. int _iHeight;
  37. T** _pMat;
  38. };
To copy to clipboard, switch view to plain text mode 

now I'd like to access data of the class with the [] operator:
Qt Code:
  1. Grid<int> *test = new Grid<int>(2, 2);
  2. test[1][1] = 1;
  3. std::cout << test[1][1] << std::endl;
  4. delete test;
To copy to clipboard, switch view to plain text mode 

everything I tried to overload the [] operator failed :/, so maybe somebody here knows how to do it???
Qt Code:
  1. T *operator[](int value) {
  2. return ???;
  3. }
  4.  
  5. const T *operator[](int value) const{
  6. return ???;
  7. }
To copy to clipboard, switch view to plain text mode 

thanks and regards
darksaga