Talk About Network

Google





Mac > Code warrior for Mac > CW9 C++ problem...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 2151 of 2233
Post > Topic >>

CW9 C++ problems with friend/protected/private?

by _googlepost@[EMAIL PROTECTED] Jul 6, 2006 at 04:20 PM

I've had to resurrect an older C++ program which built on top of some
public matrix code (LinAlg).  It was compiling properly two or three
years ago (so CW8 or perhaps CW7).  Now, with my current CW9.6 setup,
I'm getting "illegal access" compile errors.  The LinAlg library sets
up something like this:

class ElementWiseConst
{
  friend class ElementWise;
  friend class ElementWiseStrideConst;
  friend class ElementWiseStride;
  void operator=(const ElementWiseConst&);
          // is not implemented, ergo, is not allowed
  ElementWiseConst(const ElementWiseConst&);// Cloning is not allowed,
either
....
public:
		// No public constructors...
                  // ElementWiseConst(Matrix& m) would be
                  // implicitly called
  friend inline ElementWiseConst of_every(const Matrix& m) { return m;
}
  friend inline ElementWiseConst of_every(const Matrix::ConstReference&
m)
  	{ return m.ref(); }
....
}

Later on, a function goes like this:

double e2_norm(const Matrix& m1, const Matrix& m2)
{
  return of_every(m1).sum_squares(of_every(m2));
}

and the compiler now complains

Error   : illegal access from 'ElementWiseConst' to protected/private
member 'ElementWiseConst::ElementWiseConst(const ElementWiseConst &)'
     return of_every(m1).sum_squares(of_every(m2));

It seems somehow that the CW9 compiler is trying to access the
ElementWiseConst constructor, which has been disabled in the private
section of the declaration ("Cloning not allowed" comment).  I'm not
sure if CW9 is somehow trying to instantiate an object when it wasn't
before, or if it has something to do with the "friend" declaration on
"of_every()", or what.  I'll have to dig out my C++ reference books and
start figuring out all the details of constructors/friends/etc., but I
was wondering if anyone knows if CW9 tightened up on this sort of
parsing?  I'm getting similar errors with my own derived cl*****, but
the above example is within LinAlg's code, which supposedly compiled
under "gcc 2.95.3 and gcc 3.2.1", as well as giving me no previous
problems with CW7/8.

Thanks,
David Oberst, NWT Bureau of Statistics
Yellowknife, NWT, Canada
 




 1 Posts in Topic:
CW9 C++ problems with friend/protected/private?
_googlepost@[EMAIL PROTEC  2006-07-06 16:20:12 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 18:38:41 PST 2009.