We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0a38f4a commit 698fa59Copy full SHA for 698fa59
1 file changed
section4/pybind.cpp
@@ -16,6 +16,27 @@
16
17
using namespace std;
18
19
+class Point final
20
+{
21
+private:
22
+ int x = 0;
23
+public:
24
+ Point() = default;
25
+ ~Point() = default;
26
+
27
+ Point(int a) : x(a) {}
28
29
+ int get() const
30
+ {
31
+ return x;
32
+ }
33
34
+ void set(int a)
35
36
+ x = a;
37
38
+};
39
40
PYBIND11_MODULE(pydemo, m)
41
{
42
m.doc() = "pybind11 demo doc";
@@ -35,6 +56,13 @@ PYBIND11_MODULE(pydemo, m)
56
return a + b;
57
}
58
);
59
60
+ pybind11::class_<Point>(m, "Point")
61
+ .def(pybind11::init())
62
+ .def(pybind11::init<int>())
63
+ .def("get", &Point::get)
64
+ .def("set", &Point::set)
65
+ ;
66
67
68
#if 0
0 commit comments