Thank you for the C++ code—it's been very helpful!
Cheers!