Alan has shown the two ways of sharing code at run time, however the other way is to share code development, but extract separate copies of the code to be loaded into the document at run time.
That is used for the two classes that you mention:
book are almost identical in all respects except for some different defaults for
\twoside etc and some extra control over front and back matter in
These two files are extracted from the same documented source
classes.dtx by the
docstrip system that is part of the base LaTeX distribution. So the bulk of the code for
report) is only written once, but extracted separately into the three classes.
So you could write a single documented source of your classes and just mark specific lines with docstrip guards such as
stuff here for classa.sty
where you want to specify different versions in each class.