What is the best way to create and use class-type variables in KM?

As @ComplexPoint says, KM Variables have only one type: string
They are simple scalar string variables.

However, KM Dictionaries may provide what you need -- I'm not sure as I don't understand enough about your use case.

KM Dictionaries work much like JavaScript objects, but, IMO, they are much harder to use. Depending on what you want to do with the data you have entered, you may be better off using JavaScript for Automation (JXA).

You can either use JXA in standalone script files, or with KM using the Execute a JavaScript For Automation action.

With JXA (as with JavaScript) it is easy to save and restore your data using JSON.

So, if you need more help, please provide us with more details about your use case and workflow. Please read:
Tip: How Do I Get The Best Answer in the Shortest Time?