#super class and sub class

11 messages · Page 1 of 1 (latest)

hollow moon
#

Sorry if this is a stupid question, but I've noticed that you can put a sub class in the same class as the super class. Like for example, on this image, I have both Vehicle class and Car class within the same source code. Is this generally the recommended format or should I create a new class for the subclasses?

limber duneBOT
#

This post has been reserved for your question.

Hey @hollow moon! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

static maple
hollow moon
#

oh they are called nested classes

amber notch
#

in your screenshot, you don't have nested classes but two classes next to each other in the same file

#

this is possible only if the second class isn't public

hollow moon
#

oh i see

hushed rover
#

(you can only have 1 public top-level class per file, that matches the file's name)

limber duneBOT
hushed rover
#

nested classes are a thing, they're under classes & objects there ^