7.13-20The first week:Learning experience
vector
vector’s function is copy elements
#inlcude<vector>
int mian(){
vector<Man>men;
men[0].push_back(liuBei); //men.pop()
//men[0] is different with liuBei,and it is copy of liuBei
men[0].getcount();
liuBei.getcount();
}
static
The static function of class can’t access instance objects and instance data members.
inherit
Only two function can’t to inherit:constructor and destructor
subclass/superclass’s constructor and destructor
1.The constructor of static data members
2.The constructor of superclass
3. …of non-static data members
4. …of subclass
Tips:The destructor is converse.
文件流定位
#include <fstream>
#include <string>
#include <fstream>
using namespace std;
int main(void) {
ifstream infile;
infile.open("定位.cpp");
if (!infile.is_open()) {
return 1;
}
// seekg:设置输入流的位置
// seekp:设置输出流的位置
infile.seekg(0, infile.end);
// tellg:返回该输入流的当前位置(距离文件的起始位置的偏移量)
cout<<infile.tellg()<<endl;
system("pause");
return 0;
}