You must provide more information about your plan.
In general, you may generate spice input deck by your c++ code, and then load ngspice via exec system call to do the simulation.
If your circuit is quite simple (i.e. passive elements only), I think write a MNA solver is a better choice.
I want to integrate ngspice with my existing C++ program to simulate virtual circuits. Can I know how to do that?