<div dir="ltr">Hi,<div><br></div><div> This question may have been answered, but I couldn't find anything useful. So I have been writing some racket extensions for some C++ classes using the tutorial (<a href="http://docs.racket-lang.org/inside/overview.html">http://docs.racket-lang.org/inside/overview.html</a>) on the racket site and have been able to successfully load them into racket. However I was wondering if I can use inheritance to reuse some code. </div>
<div><br></div><div>For example I have two classes that I have written in C++, Foo and Bar. </div><div><br></div><div>Class Foo looks like this: </div><div><br></div><div>Foo {</div><div> func1() { /* ... do stuff */ } </div>
<div>} </div><div><br></div><div>Class Bar looks like this: </div><div><br></div><div>Bar : Foo {</div><div> func2() { /*... do more stuff /*} </div><div>} </div><div><br></div><div>I've currently written a single .cpp racket extension that creates Bar and creates the extensions for both func1() and func2(); however, I'd like to create two racket extension classes. One extension that does only functions inside Foo and then I just want to include Foo_ext.h (my racket extension to Foo) in Bar_ext.h so I have access to all the functions. </div>
<div><br></div><div>So I currently have this: </div><div><br></div><div>Bar_ext.cpp: </div><div><br></div><div>func1_racket_ext() { /*... do racket stuff and run func1() */} </div><div><br></div><div>func2_racket_ext() {/* ... do more racket stuff and run func2() /*} </div>
<div><br></div><div>/* Scheme initializes etc... */</div><div><br></div><div><br></div><div><br></div><div>But what I really want is: </div><div><br></div><div>Foo_ext.h: </div><div><br></div><div>func1_racket_ext() { /*... do racket stuff and run func1() */} <br>
</div><div><br></div><div>/* Scheme initializes etc... */<br></div><div><br></div><div><br></div><div>Bar_ext.cpp: </div><div>#include "Foo_ext.h" </div><div><br></div><div>func2_racket_ext() {/* ... do more racket stuff and run func2() /*} <br>
</div><div><br></div><div>/* Scheme initializes etc... */<br></div><div><br></div><div><br></div><div>Is this even possible? I feel like namespace might be an issue. This would be extremely useful for me because it would allow me to not write lots and lots of redundant code since I have many classes that use class Foo as a super class. </div>
<div><br></div><div>Any advice would be greatly appreciated and if you could point me to an example (maybe there is something in the underlying racket code you can point me to?) </div><div><br></div><div><br></div><div>Thanks again!</div>
<div><br></div><div>~Cody </div><div><br></div><div><br></div></div>