Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Can there be sub-sub classes?

class Product {...}
class Clothing: Product {...}
class Tops: Clothing: Products{...}

1 Answer

Conceptually yes, but it's not the syntax you're thinking of. When you subclass something, you're just adding it to the end of its parent's inheritance chain. Perhaps this will help explain:

class Product {
  //This is the base class. It is a parent of both Clothing and Top
}

class Clothing: Product{
  //This is the parent of Top, but it's a child of Product, so it gets all of Product's methods and properties
}

class Top: Clothing{
  //This is a child of both Clothing and Product. Therefore, it inherits all of the methods and properties of both classes
}