Sub Classes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the benefits of having a class within a class

Thanks in advance for the info.
 
I'm not sure these are benfits, but more why and how you should use nested
classes:

1) It's accesible only through the containing class.
2) If the class is only meaningful to one other class, why not nest it
within this other class, thus indicating to other developers the exact use
of the class.
 
It's a matter of encapsulation. It allows you to create private utility
classes that are only visible to the containing class.

One more note, though -
I've seen a few people call these sub-classes or subclasses, but the real
name is "nested class". Subclasses are classes that inherit from another
base class (or superclass).

-Rob Teixeira [MVP]
 
Subclasses are classes that inherit from another
base class (or superclass).

I prefer the term "derived class", but I guess I get that from C++, but I
know they mean the same thing.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top