📄 dlltest.cpp
字号:
#include <string>
namespace
{ // Avoid cluttering the global namespace.
// A couple of simple C++ functions that we want to expose to Python.
std::string greet() { return "hello, world"; }
int square(int number) { return number * number; }
}
#include <boost/python/class.hpp>
namespace python = boost::python;
BOOST_PYTHON_MODULE_INIT()
{
try
{
// Create an object representing this extension module.
python::module this_module("getting_started1");
// Add regular functions to the module.
this_module.def(greet, "greet");
this_module.def(square, "square");
}
catch(...)
{
python::handle_exception(); // Deal with the exception for Python
}
}
/*
#include <boost/python.hpp>
using namespace boost::python;
char const* greet()
{
return "hello, world";
}
BOOST_PYTHON_MODULE(dlltest)
{
def("greet", greet);
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -