PHP Code:
/*
a is a class
a1 and b are public subclass of class a
b inherit the class a1
c is a private subclass of class a
*/
/////////////////////// the inteface
class a{
public:
a();
int var;
class a1{
public:
a1( int in);
};
class b : public a1 {
public:
b(int in);
};
a::a1 mario;
private:
class c{
c();
};
c obj; // i can create a class c obj because i'm in the class a
b obj2;// b is a public subclass, i can create an object here and out of here
};
///////////////////// the implementation
a::a()
:var(0),
mario(10)
{}
a::a1::a1(int in)
{}
a::b::b(int in)
:a1(in)
{}
a::c::c()
{}
////////////////// main sample
int main () {
a obj1; // a in a general class
a::a1 obj2(10); // a1 is accessible because it's a public subclass of a
a::b obj3(10); // ab is accessible because it's a public subclass of a
a::c obj4; // error - c is a private subclass of a, i can declase a c object only as a class a member
}