Re: [Dev-C++] C++ standard - Nesting classes.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Michael C. <jd...@ho...> - 2001-09-26 07:39:44
|
Hi Jason, The standard states that anything in your private area is only accessable by that class. Not even public derived classes of that class can access it. The protected area is accessable by public derived classes of that class. In effect it becomes the private area of that derived class. Also, classes of the same type that get passed into an object as an argument may have their protected area accessed. i.e. Class A { public: inline mthd(Class A& obj){cout << obj.data << endl;}; protected: data; } Class A a, b; a.mthd(b); << object a can access b protected area. The public area of a class can be accessed by anyone. The story is slightly different for protected and private derived classes. For more info get Stroustrups book. http://www.research.att.com/~bs/ I would not usually have a class called main, I would normally have a public static main() function and tell my compiler which class contains main(). However, I guess this changes when you are Windows programming of which I have no experience. Could you send an example of what you are doing so we could help some more. Thanks, Michael >From: "Jason Hardman" <jas...@bt...> >Reply-To: dev...@li... >To: "Dev-C++" <dev...@li...> >Subject: [Dev-C++] C++ standard - Nesting classes. >Date: Wed, 26 Sep 2001 03:03:24 +0100 > >Hi, > >In a project I have been working on I have nested some classes within a >main >class that provides an overall functionality. I wanted to make these >internal classes inaccessible to anyone using the main class. I had hoped >that putting them in a private or protected area of the main class it would >stop outside access, but this doesn't seem to work in Dev-C++ (MinGW). Does >anyone know if that is standard C++ behaviour? None of my C++ books say >anything about access specifiers and nested classes, and they say pretty >little about nested classes full-stop. It could reasonally be that only >data >and methods are affected by access specifiers, but it's hard for me to be >sure. > >I am now looking for an alternative way of hiding those classes, although I >have found some interesting options in using an implementation namespace, I >am still interesting in hearing any other ideas? > >Thanx, Jason. > > >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp |