diff --git a/cheatsheet.md b/cheatsheet.md index 6bde03fe..a4f74384 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -92,6 +92,7 @@ chai.add(chaiscript::user_type(), "MyClass"); User defined type conversions are possible, defined in either script or in C++. + ### ChaiScript Defined Conversions Function objects (including lambdas) can be used to add type conversions @@ -115,6 +116,21 @@ Calling a user defined type conversion that takes a lambda chai.add(chaiscript::type_conversion([](const TestBaseType &t_bt) { /* return converted thing */ })); ``` +### Class Hierarchies + +If you want objects to be convertable between base and derived classes, you must tell ChaiScritp about the relationship. + +``` +chai.add(chaiscript::base_class()); +``` + +If you have multiple classes in your inheritance graph, you will probably want to tell ChaiScript about all relationships. + +``` +chai.add(chaiscript::base_class()); +chai.add(chaiscript::base_class()); +chai.add(chaiscript::base_class()); +``` ### Helpers