Welcome to MacBoardz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

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

 
   Macintosh computer (Home) -> Programmer Code RSS
Next:  Allow editing in a protected document  
Author Message
_googlepost

External


Since: Jul 06, 2006
Posts: 1



(Msg. 1) Posted: Thu Jul 06, 2006 4:20 pm
Post subject: CW9 C++ problems with friend/protected/private?
Archived from groups: comp>sys>mac>programmer>codewarrior (more info?)

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 classes, 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

 >> Stay informed about: CW9 C++ problems with friend/protected/private? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
"illegal 'friend' declaration" - I have a class that looks like this: class Pausable { protected: friend PausableMgr; virtual void pause() = 0; virtual void resume() = 0; }; It works as expected, and PausableMgr is able to call pause and resume on Pausable objects. However, ...

Error trying to use a friend operator*() - Hi all, The namespace is blaster. In Vector3.h I declare. class Vector3f { // Friend declaration. friend Vector3f operator* (float pScalar, const Vector3f& vect); .... }; In Vector3.cpp I define. Vector3f operator* (float pScalar, const Vector3f&a...

Private framework - Hi! I would like to use a 3rd-party distributable framework, "FW.framework" in my application bundle. Everything works fine when the FW is in the Libraries/Frameworks system folder. However, when I move it into my App/Contents/Frameworks &quot...

Private Framework - I'm trying to use private frameworks in my MachO application (I will do the same thing with Bundles later...). Then, I've created a FrameWork called MyFramework and created an Application Package. I've included the framework in app package. Then, I've..

Private umbrella framework? - Is it possible to build a private umbrella framework? I have not idea what to put in the "Install Path" setting for the sub-umbrellas. Perhaps it is not possible at all? Is there a better place to ask? Yvo -- Dipl.-Inform. Yvo Van Wezemael...
   Macintosh computer (Home) -> Programmer Code All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]