c– 在boost :: python的类中公开public struct

c– 在boost :: python的类中公开public struct,第1张

概述我想用boost :: python将这个C类用于python代码/* creature.h */ class Human { private: public: struct emotion { /* All emotions are percentages */ char joy; char trus

我想用boost :: python将这个C类用于python代码

/* creature.h */class Human {private:public:    struct emotion {        /* All emotions are percentages */        char joy;        char trust;        char fear;        char surprise;        char sadness;        char disgust;        char anger;        char anticipation;        char love;    };};

问题是如何在boost-python中公开这个公共属性

namespace py = boost::python;BOOST_PYTHON_MODulE(example){    py::class_
最佳答案当类型通过Boost.Python公开时,它们被注入到current scope中.某些类型(例如与class_一起引入的类型)可以用作当前范围.

这是一个完整的注释示例:

#include 

交互式Python:

>>> import example>>> e = example.Human.Emotion>>> e
总结

以上是内存溢出为你收集整理的c – 在boost :: python的类中公开public struct全部内容,希望文章能够帮你解决c – 在boost :: python的类中公开public struct所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1205284.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)