Basing one class on another is called inheritance. : inheritance « Class « Ruby






Basing one class on another is called inheritance.


# Creating a class named A and then using the A class as a base class for another class, B:
# Note that the syntax class B < A indicates that the B class inherits all that A class has


class A
.
.
.
end

class B < A
.
.
.
end

 








Related examples in the same category

1.Extends class
2.how inheritance works in code form
3.Basing One Class on Another: a Demo
4.different types of people
5.Structuring Your Pets Logically
6.If the class Name were in a different file, you would just require that file first
7.Add new constructor
8.Module and class hierarchy
9.Subclass Array class