Fixed bug in C++ version

See plumed/plumed2@53b56a186d0f40850602