Nested classesNested class is a class declared inside another class:
class Editor {
int x;
class Nested {
int y;
};
};Nested classes are
not inheritance. Inheritance would be wrong in the OP's design, an Editor cannot be used where a Style is required, nor can a Style be used where an editor is required.
C++ nested classes are like
static inner classes in D or Java. C++ nested classes cannot access any outside object of the enveloping class. You can have an Editor::Nested and no Editor, that will work perfectly fine, it has one field Editor::Nested::y. There is no pointer to any Editor within the Editor::Nested, and there is no Editor::Nested::x because that's a field of Editor, an unrelated class.
The point of nesting is naming and possibly implementation hiding. Within Editor, the Nested is called Nested, whereas outside of the Editor, the class is called Editor::Nested. You can declare class Nested private with the usual effects: The symbol is not visible outside of Editor.
I would not use nested classes because most of the application is an editor, therefore Editor::Nested doesn't gain much over naming it Nested. But the design is not wrong either.
Everything elseThe design issue from OP arises in any object-oriented language, not merely in C++.
Yes, your code in C++ gets longer than in most other languages. You can hide the allocation in wrapper structs or the standard library's unique/shared/weak pointers. But you choose C++ in the first place only when you want the low level, and have ruled out D/Rust/Crystal/... for whatever reason. Learning some C++ can't hurt either, the language is really common.
I basically brute-forced everything.
The type system is your best friend, do not betray it.
But yes, it requires some proficiency to become useful in the first place.
-- Simon