Skip to content

Is there a way to turn Base class instance into Derived class instance? #643

Answered by wjakob
JiauZhang asked this question in Q&A
Discussion options

You must be logged in to vote

Actually, let me fix that.

nb::object inst = nb::module_::import_("my_module").attr("Derived")(.. constructor arguments ..);
MyType &ref = nb::cast<MyType &>(inst);
ref = ...

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@JiauZhang
Comment options

@wjakob
Comment options

@wjakob
Comment options

Answer selected by JiauZhang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants