Inner classes: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: Add a Raku example)
m (Fixed typos.)
Line 2: Line 2:


;Definition
;Definition
In [[wp:Object-oriented_programming|object-oriented programming]], an '''inner''' or '''nested''' class is a class declared entirely within the body of another class or interface.
In [[wp:Object-oriented_programming|object-oriented programming]], an '''inner''' or '''nested class''' is a class declared entirely within the body of another class or interface.


It is not the same as a '''subclass''' which is a class which inherits members from another class or classes and can be declared anywhere the parent class(es) are within scope. However, inner classes may nevertheless be subclasses of other classes as well.
It is not the same as a '''subclass''' which is a class which inherits members from another class or classes and can be declared anywhere the parent class(es) are within scope. However, inner classes may nevertheless be subclasses of other classes as well.
Line 11: Line 11:
Illustrate your answer by creating an inner class with a constructor, an instance method and field and show how to instantiate it.
Illustrate your answer by creating an inner class with a constructor, an instance method and field and show how to instantiate it.


If you language does not support the object oriented paradigm, you may either omit this task or describe (and substitute in your example) any equivalent structure(s) which the language does have.
If your language does not support the object oriented paradigm, you may either omit this task or describe (and substitute in your example) any equivalent structure(s) which the language does have.


;Reference
;Reference