A segmentation fault means your program has been corrupting memory and you got lucky and the OS noticed it and put a stop to id before things got out of hand. If you were unlucky, the program might have just kept running! Imagine the horror!
Well, the issue is line 5. The string "name" is global. When you reach line 37, you take input and put it into name. Line 38 has you pass that value to NS.setName, which sets... name equal to the value passed to it. Which is "name" itself. If you look at line 29, you also created a string called "name" inside of the class. So when you get to NS.setName, specifically line 12, which name does it mean? setPrefix comes with the same issue- you are using a variable that is declared both as a global and as a member of a class, without distinction.