RE: [Dev-C++] C++ standard - Nesting classes.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ya...> - 2001-09-26 11:09:45
|
You are right. The following code compiles in Dev-C++:
class A
{
public:
enum errors{ MEMORY, DISK, MONITOR};
private:
class E
{
errors e;
public:
E(errors er):e(er) {}
};
};
int main()
{
A a;
=20
A::errors e;=20
=20
A::E x(e); // Mistake, E is private
}
This shouldn't compile, so i consider it a compiler defect. Borland C++
5.5 gives the (expected) error:
Error E2247 temp.cpp 23: 'A::E' is not accessible in function main()
*** 1 errors in Compile ***
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
* Alternative URL: http://run.to/noicys
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Jason Hardman
> Sent: Wednesday, September 26, 2001 4:03 AM
> To: Dev-C++
> Subject: [Dev-C++] C++ standard - Nesting classes.
>=20
>=20
> Hi,
>=20
> In a project I have been working on I have nested some=20
> classes within a main class that provides an overall=20
> functionality. I wanted to make these internal classes=20
> inaccessible to anyone using the main class. I had hoped that=20
> putting them in a private or protected area of the main class=20
> it would stop outside access, but this doesn't seem to work=20
> in Dev-C++ (MinGW). Does anyone know if that is standard C++=20
> behaviour? None of my C++ books say anything about access=20
> specifiers and nested classes, and they say pretty little=20
> about nested classes full-stop. It could reasonally be that=20
> only data and methods are affected by access specifiers, but=20
> it's hard for me to be sure.
>=20
> I am now looking for an alternative way of hiding those=20
> classes, although I have found some interesting options in=20
> using an implementation namespace, I am still interesting in=20
> hearing any other ideas?
>=20
> Thanx, Jason.
>=20
>=20
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>=20
|