Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typo in the documentation #1514

Closed
OndrejPopp opened this issue Jul 21, 2023 · 0 comments · Fixed by #1548
Closed

Typo in the documentation #1514

OndrejPopp opened this issue Jul 21, 2023 · 0 comments · Fixed by #1548

Comments

@OndrejPopp
Copy link

Hi, tx for making this library!
I am making a C++ -> Lua bridge from a set of C++ classes I already wrote, and so I did some documentation reading, and found a typo
It's over here,

https://sol2.readthedocs.io/en/latest/api/usertype.html#usertype-inheritance

in the statement,

                   ______________ over there B should be A
                 /
lua.new_usertype<B>( "A",
	"call", &A::call
    );

Ok, that was it.
Tx!

Ondrej

#define SOL_ALL_SAFETIES_ON 1
#include <sol/sol.hpp>

struct A {
int a = 10;
virtual int call() { return 0; }
virtual ~A(){}
};
struct B : A {
int b = 11;
virtual int call() override { return 20; }
};

int main (int, char*[]) {

sol::state lua;
                    ______________ over there B should be A
                  /
lua.new_usertype<B>( "A",
	"call", &A::call
);

lua.new_usertype<B>( "B",
	"call", &B::call,
	sol::base_classes, sol::bases<A>()
);

return 0;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant