Tuesday, December 15, 2009

Nesting of classes : Introduction

It is possible to define a class within another class; such classes are known as nested classes.

The scope of a nested class is bounded by the scope of its enclosing class. Also a nested class has access to the members, including private members, of the class in which it is nested. However, the
enclosing class does not have access to the members of the nested class.

Consider the case that class B is defined within class A. So it means:
  • B is known to A, but not outside of A. 
  • B as has access to A's members, including private members.
See types of nested classes .

    No comments:

    Post a Comment

    Chitika