Image

Imagechumducky wrote in Imagecpp puzzled

Anyone see anything wrong with this?

When compiling under GCC3.2 (20020903), I recieve the following error:

../../include/thing.hh: In function `std::ostream&
operator<<(std::ostream&, prog::Thing&)':
../../include/maths/thing.hh:29: `float prog::Thing::matrix[16]' is protected
thing.cpp:518: within this context


In thing.hh:
class Thing
{
protected:
  float matrix[16];
public:
  Thing(void) {};

...Assume other member methods

  friend ostream & operator<< (ostream & pStr, const Thing & mmm);
};


In thing.cpp:

ostream & operator<< (ostream & pStr, const Thing & ttt) 
{ 
  short unsigned int iii;
  pStr << "{" << endl << "\t ";
  for (iii=0; iii<16; iii++) {
    pStr << ttt.matrix[iii];
    if ((iii%4)==0) {
      pStr << endl << "\t ";
    } else {
      pStr << ", ";
    }
  }
  pStr << endl << "}";
  return pStr;
}



Anyone see the error? As far as I know a friend function should be able to access private members, not to mention protected members, but even if I shuffle the data into the private section I receive the same error. The odd part of the error is that if I move the method inline (into the header); the error vanishes! Likewise, if I delete the whole kibitz and kibbiddle (method and definition) everything compiles.

I've followed examples from elsewhere and none of them work. You all are my last resort.

Suggestions?