Function to create a sphere data:
When you use MString in your code, do remember to include the header file "<maya/MString.h>". Moreover, in C++, you must not use following format:
cmd="sphere -r "+radius;
cmd="sphere -r ";
As MString class has provide the operator +=, in this way it will work correctly. Or, using the first format, the "+" won't work well. And usually, it cause the cmd string to be "".