[gecode-users] Starting with C++

Malcolm Ryan malcolmr at cse.unsw.edu.au
Wed Nov 19 05:06:27 CET 2008


Given that GecodeJ is no longer supported, I'm in the process of  
migrating my code to C++ (and learning C++ in the process).

It seems from my perusal of the examples that the C++ library works  
slightly differently. Whereas in java the copy constructors for spaces  
look like:

   public Queens(Boolean share, Queens queens) {
     super(share, queens);
     n = queens.n;
     q = new VarArray<IntVar>(this, share, queens.q);
   }

in C++ they look like:

   /// Constructor for cloning \a s
   Queens(bool share, Queens& s) : Example(share,s) {
     q.update(this, share, s.q);
   }

The Java code explicitly contructs a new var array from the old. The C+ 
+ code seems to implicitly construct an empty var array and then call  
'update' to copy the old into the new. Is that correct? Does every  
kind of variable have an no-arg constructor? What is the rationale for  
this choice? It seems that it allows you to construct variables in an  
incompletely initialised state. Is that deliberate?

Malcolm




More information about the gecode-users mailing list