#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
int a;
int b[80];
string s;
string sd[4];
char c;
char cs[6];
//if(a==0) cout << "s";
//cout << a << endl;
//cout << b[5] << endl;
cout << s << endl;
cout << sd[3] << endl;
//cout << c << endl;
//cout << cs[2] << endl;
vector<int> v(45);
vector<char> vc(45);
vector<string> vs(89);
vector<double> vd(65);
vector<long long> vl(155);
map<string,int> m;
map<int,string> ms;
map<string,double> md;
map<string,long long> ml;
cout << v[6] << endl;
cout << vs[7] << endl;
cout << vc[7] << endl;
cout << vd[64] << endl;
cout << vl[61] << endl;
cout << m["f"] << endl;
cout << ms[5] << endl;
cout << md["sdfsdf"] << endl;
cout << ml["fsdf"] << endl;
return 0;
}
总结:
在数组中,int型,char型使用前需初始化或赋值,否则会在运行时出错。而string型初始化为空。
而在vector中int,double,long long型均被初始化为0,而string,char被初始化为空。map中int,double与long long型的值初始为0,string初始为0。(这样说可能不太准确,不过大概就是这意思)
故:c++大法好,舍弃过时的数组来用vector吧。(振臂高呼)