vector的问题,求解aaa!!!!
程序代码:
// Note:Your choice is C++ IDE #include #include #include using namespace std; int main() { vector myvector(5,""); cout<<"len is:\n"<就行了啊?
// Note:Your choice is C++ IDE #include <string> #include <iostream> #include <vector> using namespace std; int main() { vector<string> myvector(5,"1"); cout<<"len is:\n"<<myvector.size()<<endl <<"content is\n"<<myvector[0]; return 0; } //能运行 但是要报错 // Note:Your choice is C++ IDE #include <string> #include <iostream> #include <vector> using namespace std; int main() { vector<int> myvector(5,1); //改为int cout<<"len is:\n"<<myvector.size()<<endl <<"content is\n"<<myvector[0]; return 0; } //不报错了 为什么啊 是因为string 不是内置类型吗?