add the new CPP API and add sample code.