Skip to content

Instantly share code, notes, and snippets.

@VanyaBelyaev
Last active September 3, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VanyaBelyaev/1f06b43994b23d52fef42d03db1e15a8 to your computer and use it in GitHub Desktop.
Save VanyaBelyaev/1f06b43994b23d52fef42d03db1e15a8 to your computer and use it in GitHub Desktop.
from __future__ import print_function
import ROOT
ROOT.gROOT.ProcessLine("""
#include <string>
class A
{
public:
A ( int a )
: m_a ( a )
{} ;
virtual ~A(){};
virtual int num () const { return m_a ; }
std::string line () const
{ return std::to_string ( this->num() ) ; }
private:
int m_a {0};
};
""")
class B (ROOT.A) :
def __init__ ( self , b ) :
ROOT.A.__init__ ( self , b )
def a (self ) : return 10
a = ROOT.A ( 5 )
print ('A-line', a.line() )
b = B ( 6 )
print ('B-line', b.line() )
"""
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/afs/cern.ch/user/i/ibelyaev/cmtuser/RELEASE/ostap/build/tst40.py in <module>()
35 print ('A-line', a.line() )
36
---> 37 b = B ( 6 )
38
39 print ('B-line', b.line() )
/afs/cern.ch/user/i/ibelyaev/cmtuser/RELEASE/ostap/build/tst40.py in __init__(self, b)
26
27 def __init__ ( self , b ) :
---> 28 ROOT.A.__init__ ( self , b )
29
30 def a (self ) : return 10
TypeError: none of the 2 overloaded methods succeeded. Full details:
no constructor available for 'A'
A::A(A&) =>
TypeError: could not convert argument 1
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment