[Rcpp-devel] inheritance

Dirk Eddelbuettel edd at debian.org
Wed Oct 5 00:23:42 CEST 2011


Richard,

Welcome!

On 4 October 2011 at 16:29, Richard Downe wrote:
| Is it possible to have a class wrapped in rcpp inherit directly from a 
| superclass?
| E.g., I have
| 
|      class_<tcfaIndices>( "tcfaIndices" )
| 
|          .constructor<long>()
| 
|          .method("SetTCFADefinition", &tcfaIndices::SetTCFADefinition)
|          .method("getTCFALabels", &tcfaIndices::getTCFALabels)
| 
|          ;
| 
| and
| 
|      class_<morphologyIndices>( "morphologyIndices" )
| 
|      .constructor<long>()
| 
|          .method("getCentroidLumen", &morphologyIndices::getCentroidLumen)
|          .method("getCentroidAdventitia", 
| &morphologyIndices::getCentroidAdventitia)
| 
|          ;
| 
| where the c++ class tcfaIndices inherits from c++ class morphologyIndices.
| I get compiler errors that suggest this is impossible (they seem to show 
| up surrounding the cascade of calls to constructors), but was curious as 
| to if there's a way to do this (other than, say, introducing 1 more 
| level of abstraction, and then inserting a member variable rather than a 
| parent class...)

Rcpp itself is open to mulitple inheritance.

Rcpp modules, which your question appears to be concerned with, currently
cannot as discussed a few times on this list.  You find perusing the list
archives informative.

Hth, Dirk

-- 
New Rcpp master class for R and C++ integration is scheduled for 
San Francisco (Oct 8), more details / reg.info available at
http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php


More information about the Rcpp-devel mailing list