vector::size_type类型是无符号类型,通常是unsigned , 大于 0的整数
unsigned char是无符号字节型,char类型变量的大小通常为1个字节(1字节=8个位),且属于整型。整型的每一种都有无符号(unsigned)和有符号(signed)两种类型(float和double总是带符号的),在默认情况下声明的整型变量都是有符号的类型(char有点特别),如果需声明无符号类型的话就需要在类型前加上unsigned。无符号版本和有符号版本的区别就是无符号类型能保存2倍于有符号类型的数据,比如16位系统中一个int能存储的数据的范围为-32768~32767,而unsigned能存储的数据范围则是0~65535。
vector<string> stu_id; //申明空字符向量
cout << stu_id.size() << endl; //此空字符向量大小为0
for (int n = 0; n < stu_id.size() - 1; n++) // 输出一大堆数据
{
cout << n <<" ";
}
********************************************************************************
vector<string> stu_id;
int len = stu_id.size() ;
for (int n = 0; n < len - 1; n++) //无输出
{
cout << n <<" ";
}
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
string str;
int people_num = 0, t_num = 0, score = 0;
vector<int> score_list(t_num, 0);
vector<string> stu_id;
cout << stu_id.size() << endl;
for (int n = 0; n < stu_id.size() - 1; n++)
{
cout << n <<" ";
}
cout << endl;
system("pause"