Skip to content
Prev 2704 / 10988 Next

[Rcpp-devel] Overloaded constructors?

Hi!

Well, I am not that familiar with details of how Rcpp has to work things out, but the job its doing is really great (I would never be able to extend R with C++ code without Rcpp). The situation I am dealing with is something like this:

class A {
public:
A(int argument) {}
A(std::string name) {}
};

Now, given such a class - is there a way to distinguish the two constructors? The way I understand the code in the Rcpp module is to allow for different constructors with different numbers of arguments, but overloaded constructors like the above case are out of scope at the moment. Maybe I have to live with it, but I think there should be a solution to it (i.e. employing singleton factories of the objects). 

The case for methods is greatly solved for example by function pointers to class members or even to function pointers to c++ functions taking as first argument a pointer to the class. BTW, I discovered this very cool feature by reading the code, but there is no documentation yet, right? Does the feature stay in Rcpp?

Cheers,

Sebastian

Am 05.08.2011 um 18:54 schrieb Dirk Eddelbuettel: