c++ day7

c++ day7_第1张图片

list 的了解:

#include 
#include 
using namespace std;
void output(list &T)
{
    list::iterator itr;
    for(itr=T.begin();itr!=T.end();itr++)
    {
        cout<<*itr <<" ";
    }
    cout< T(6,15);
    cout< T1;
    T1.assign(6,14);
    cout<<"T1: ";
    output(T1);
    T.swap(T1);
    cout<<"T: ";
    output(T);
    cout<<"T1: ";
    output(T1);
    T.push_back(15);
    cout<<"T: ";
    output(T);
    T1.pop_back();
    cout<<"T1: ";
    output(T1);
    T.pop_front();
    cout<<"T: ";
    output(T);
    list::iterator itr;
    itr=T1.begin();
    itr++;itr++;itr++;
    T1.insert(itr,2,99);
    cout<<"T1: ";
    output(T1);
    return 0;
}

c++ day7_第2张图片

c++ day7_第3张图片

完成编程

#include 
#include 
#include 
using namespace std;
class Stu
{
    friend ifstream & operator>>(ifstream &ifs,Stu &s);
    friend ostream & operator<<(ostream &cout,const Stu &s);
    friend ofstream &operator<<(ofstream &ofs,const Stu &s);
    string name;
    int age;
public:
    Stu() {}
    Stu(string name,int age):name(name),age(age)
    {}
    ~Stu()
    {}
};

ofstream & operator<<(ofstream &ofs,const Stu &s)
{
    ofs<>(ifstream &ifs,Stu &s)
{
    ifs >>s.name >>s.age;
    return ifs;
}

ostream & operator<<(ostream &cout,const Stu &s)
{
    cout< v1(3,s);
    ofstream ofs;
    ofs.open("D:/hqyjc++/1/stu.txt",ios::out);
    vector::iterator iter;
    for(iter=v1.begin();iter!=v1.end();iter++)
    {
        ofs<<*iter < v2;
    Stu temp;
    while(ifs >> temp)
    {
        v2.push_back(temp);
    }

    vector::iterator itr;
    for(itr=v2.begin();itr!=v2.end();itr++)
    {
        cout <<*itr <

c++ day7_第4张图片

c++ day7_第5张图片

思维导图:

你可能感兴趣的:(c++,开发语言)