#include "stdafx.h"#include <iostream> #include <string>extern int myfirst();int main(){ string switch_on = "myfirst"; switch (switch_on) { default: break; } myfirst(); //int a; //cin >> a; system("pause"); return 0;}
string是std命名空间里的,所以要加上using namespace std;或者这样using std::string;或者更麻烦点,在定义的时候std::string switch_on = "myfirst";也行