View Single Post
Old 02-02-2005, 11:11 PM   #12 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Originally your code created an instance of struct "object".
(Don't name your structs, classes, and types with only lower case letters next time).
Code:
object * start;
  start = new object;
And your struct set us up a matrix of ints.
Code:
struct object
{
  //For now, lets test on a 5x5 matrix
  object()
  {
     array = new C2DVector<int>(5,5);
  }

  C2DVector<int> *array;
};
That means: that is the intention, looking at the declaration of C2DVector<int>*.
But this code is faulty anyway (although compilers accept it!).
So I've adapted it:
Code:
class object 
{
public:
  object() : array(2,2) //  this has been changed now.
  { }  
  C2DMatrix<int> array;
};
So I haven't changed anything. If I did, then your struct is ambigious.

All in all, this stuct of int-matrices work perfectly:
Code:
class object 
{
public:
  object() : array(2,2)
  { }  
  C2DMatrix<int> array;
};


int main()
{  
  try
  {
    object start;
    
    start.array(0,0)=1;
    start.array(1,1)=2;
    cout<<start.array<<endl;
  }
  catch(C2DMatrixError& err)
  {
    cout<<err.what()<<endl;
  }
    
  return 0;
}
__________________
Valmont is offline   Reply With Quote