mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 23:00:18 +00:00
This is not a highlightable cpp code block
This commit is contained in:
@@ -96,26 +96,27 @@ Example: Overloading __repr__
|
|||||||
std::string getName();
|
std::string getName();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
:file:`myclass.i`
|
:file:`myclass.i`
|
||||||
|
|
||||||
.. code-block:: c++
|
.. code-block::
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
%include "string.i"
|
%include "string.i"
|
||||||
|
|
||||||
%module myclass
|
%module myclass
|
||||||
%{
|
%{
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "MyClass.h"
|
#include "MyClass.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%extend MyClass {
|
%extend MyClass {
|
||||||
std::string __repr__()
|
std::string __repr__()
|
||||||
{
|
{
|
||||||
return $self->getName();
|
return $self->getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%include "MyClass.h"
|
%include "MyClass.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user