有关switch 和 if...else if的请教
小弟看到很多c/c++源码中关于命令的截取都使用了大量的if...else if...,方式,为何不使用switch方式?是不是他们编译后的处理方式一样,还是怎么的?
if(command=="AUTHENTICATE" ||
command=="LOGIN")
error("Sorry, already authenticated");
else if(command=="SELECT" ||
command=="EXAMINE")
doselect();
else if(command=="CREATE")
docreate();
else if(command=="NAMESPACE")
donamespace();
else if(command=="GETACL")
dogetacl();
else if(command=="LISTRIGHTS")
dolistrights();
else if(command=="MYRIGHTS")
domyrights();
else if(command=="SETACL")
dosetacl();
else if(command=="DELETEACL")
dodeleteacl();
else if(command=="DELETE")
dodelete();
else if(command=="RENAME")
dorename();
else if(command=="SUBSCRIBE")
dosubscribe(true);
else if(command=="UNSUBSCRIBE")
...............