Hi,
I am using VC++6, MFC Application

I am having the member variable - CArray < Coordinates, Coordinates & > mCoordinates. Coordinates is a structure, contains x, y, and z. When i return reference to this object, there is no problem. but When i assign to some reference i get problem.

The Code is

struct Coordinates{
  int x, y, z;
};
class A{
   private:
   CArray < Coordinates, Coordinates & > mCoordinates
   public: CArray < Coordinates, Coordinates & > & GetCoordinates() {
         return mCoordinates;
   }
};

class B {
  public:
     void Print () {
          A objA;
          CArray < Coordinates, Coordinates & >  &ref = objA.GetCoordinates (); 
     }
}

In Class B's Print () function, i am getting problem when assign the coordinates. Compiler says different level of indirection. Anyone suggest me how to solve this.

I changed the reference as pointer that also not working. Finally i found the solution. I just inherit a class from CArray <>, that solves the problem.

struct Coordinates{
  int x, y, z;
};
class CoordinateArray : public CArray < Coordinates, Coordinates & > {};
class A{
   private:
   CoordinateArray mCoordinates
   public: CoordinateArray & GetCoordinates() {
         return mCoordinates;
   }
};

class B {
  public:
     void Print () {
          A objA;
          CoordinateArray  &ref = objA.GetCoordinates (); 
     }
}
This question has already been answered. Start a new discussion instead.