<div dir="ltr"><div>Hi folks, </div><div><br></div><div>I'm building several Rcpp modules which specify parts of a complicated statistical model, and want to pass them to a main module for use. Is there an easy way to do this? </div><div><br></div><div>Below is a simplified example, with question marks where I'm not sure what to do. I've tried accepting a pointer to A, playing with using XPtrs, and a bunch of things which made far less sense, but so far no luck. </div><div><br></div><div>Any suggestions or links to sections of the docs I should revisit would be appreciated. </div><div><br></div><div>Thanks,</div><div>-Grant<br></div><div><br></div><div><br></div><div>## file: A.cpp</div><div><br></div><div>class A</div><div>{</div><div><span class="" style="white-space:pre">       </span>public:</div><div><span class="" style="white-space:pre">            </span>A();</div><div><span class="" style="white-space:pre">               </span>~A();  </div><div>};</div><div><br></div><div>class B</div><div>{</div><div><span class="" style="white-space:pre">   </span>public:</div><div><span class="" style="white-space:pre">            </span>B();</div><div><span class="" style="white-space:pre">               </span>void DoSomethingWithInstanceOfA(???);</div><div><span class="" style="white-space:pre">              </span>~B();</div><div>};</div><div><br></div><div>A::A()</div><div>{</div><div><span class="" style="white-space:pre">       </span>// Do stuff</div><div>}</div><div><br></div><div>B::B()</div><div>{</div><div><span class="" style="white-space:pre">  </span>// Do stuff</div><div>}</div><div><br></div><div>B::DoSomethingWithInstanceOfA(???)</div><div>{</div><div><span class="" style="white-space:pre">      </span>// Do stuff</div><div>}</div><div><br></div><div><div>RCPP_MODULE(mod_A)</div><div>{</div><div><span class="" style="white-space:pre">   </span>using namespace Rcpp;</div><div><span class="" style="white-space:pre">      </span>class_<A>( "A" )</div><div><span class="" style="white-space:pre">   </span>.constructor();</div><div>}</div></div><div><br></div><div>RCPP_MODULE(mod_B)</div><div>{</div><div><span class="" style="white-space:pre">      </span>using namespace Rcpp;</div><div><span class="" style="white-space:pre">      </span>class_<B>( "B" )</div><div><span class="" style="white-space:pre">   </span>.constructor()</div><div><span class="" style="white-space:pre">     </span>.method("DoSomethingWithInstanceOfA", &B::DoSomethingWithInstanceOfA);</div><div>}</div><div><br></div><div><br></div><div>### End pseduo c++ code</div><div><br></div><div><br></div></div>