Fixing the old C-style API in C++ samples as mentioned in feature 1631