[Rcpp-devel] Module with out default constructor.
Andrew Redd
amredd at gmail.com
Wed Oct 27 21:32:21 CEST 2010
Is it possible with Rcpp Modules to have a class that does not have a
default constructor? Consider this example
-----
#include <R.h>
#include <Rcpp.h>
class c1{
private:
int n;
int * x;
c1();
public:
c1(int n):n(n){}
int getn(){return n;}
};
RCPP_MODULE(c1){
using namespace Rcpp;
class_<c1>("c1")
.property("n",&c1::getn)
;
}
-----
Here I have a class that I do not want to allow to initialize without
specifying n. Yes it does not do anything but the question is related to a
class where constructors and destructors allocate and free special memory.
And Yes I know that this fails on compile since c1() is private. Can Rcpp
handle this kind of setup? If not suggestions about workarounds?
thanks,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20101027/36c4dc56/attachment.htm>
More information about the Rcpp-devel
mailing list