当前位置: 首页 > news >正文

icp备案网站百度搜索引擎的功能

icp备案网站,百度搜索引擎的功能,江苏华东建设基础工程有限公司网站,wordpress 微信主题下载作业: 封装一个学生的类,定义一个学生这样类的vector容器, 里面存放学生对象(至少3个) 再把该容器中的对象,保存到文件中。 再把这些学生从文件中读取出来,放入另一个容器中并且遍历输出该容器里的学生。…

作业:

封装一个学生的类,定义一个学生这样类的vector容器, 里面存放学生对象(至少3个)

再把该容器中的对象,保存到文件中。

再把这些学生从文件中读取出来,放入另一个容器中并且遍历输出该容器里的学生。

#include <iostream>
#include<vector>
#include<fstream>
using namespace std;class Stu
{friend istream & operator>>(istream &cin,Stu &R);friend ostream & operator<<(ostream &cout,const Stu &R);
private:string name;int age;
public:Stu(){};Stu(string name,int age):name(name),age(age){};
};ostream & operator<<(ostream &cout,const Stu &R)
{cout << R.name << " ";cout << R.age << endl;return cout;
}istream & operator>>(istream &cin,Stu &R)
{cin >> R.name;cin >> R.age;return cin;
}
int main()
{Stu s1("张三",18);Stu s2("李四",20);Stu s3("王五",19);vector<Stu> stu;stu.push_back(s1);stu.push_back(s2);stu.push_back(s3);ofstream ofs;ofs.open("D:/2.txt",ios::out);vector<Stu>::iterator iter;for(iter = stu.begin();iter!=stu.end();iter++){ofs << *iter ;}ofs.close();vector<Stu>stu1;Stu s;ifstream ifs;ifs.open("D:/2.txt",ios::in);while(ifs>>s){stu1.push_back(s);}for(iter=stu1.begin();iter!=stu1.end();iter++){cout << *iter ;}ifs.close();return 0;
}

 1.模板类

#include <iostream>using namespace std;template < class T,class N>
class A
{
private:T t;N n;
public:A(){};//无参构造A(T t,N n):t(t),n(n){}//有参构造void show(){cout << t << endl << n << endl;}
};
int main()
{A<string,int> a("张三",18);a.show();return 0;
}

2.异常(异常情况为取钱时取的钱小于0或者大于余额)

#include <iostream>using namespace std;class BankAccount
{
private:double balance;
public:BankAccount(){};BankAccount(double balance):balance(balance){};void withdraw(double money){if(money<0){throw(invalid_argument("取款金额不能为负数"));}else if(money>balance){throw(runtime_error("余额不足"));}else{balance -= money;cout << "余额为:" << balance << endl;}}
};int main()
{BankAccount account1(1000);try {account1.withdraw(-100);} catch (invalid_argument &e){cout << "Erro:" << e.what() << endl;} catch (runtime_error &e){cout << "Erro:" << e.what() << endl;}try {account1.withdraw(1500);} catch (invalid_argument &e){cout << "Erro:" << e.what() << endl;} catch (runtime_error &e){cout << "Erro:" << e.what() << endl;}try {account1.withdraw(500);} catch (invalid_argument &e){cout << "Erro:" << e.what() << endl;} catch (runtime_error &e){cout << "Erro:" << e.what() << endl;}return 0;
}

3.lambda表达式和auto的使用

#include <iostream>using namespace std;int main()
{int a=100;double b=3.14;char c='a';auto fun=[a,b,c](){};//捕获外界a,b,c变量的值,fun函数中的a,b,c不是外界的a,b,c,地址不同,//想要修改fun中的a,b,c的值,必须在()后加上mutableauto fun1=[=](){};//捕获外界所有的变量值auto fun2=[&a,&b](){};//捕获外界a,b变量的地址,fun函数中的a,b是外界的a,b,地址相同,//想要修改fun2中的值,可以直接改变auto fun3=[&](){};//捕获外界所有的变量的地址auto fun4=[=,&a,&b](){};//捕获外界所有的值,但是变量a和变量b是引用捕获,//fun函数中的a,b是外界的a,b,地址相同,可以直接修改,不用加上mutableauto fun5=[&,a,b](){};//捕获外界所有变量的地址,但变量a,b捕获的是值,修改需要加mutablereturn 0;
}

4.容器

#include <iostream>
#include<vector>
using namespace std;void printVector(vector<int> &v)
{vector <int>::iterator ite;//创建一个vector<int>类型的迭代器itefor(ite=v.begin();ite!=v.end();ite++){cout << *ite << ' ';}cout << endl;
}
int main()
{//容器vector<int>v;//无参构造容器vv.push_back(10);//尾插v.push_back(20);v.push_back(30);v.push_back(40);//算法printVector(v);vector<int>v2(v.begin(),v.end());//拷贝v中begin到end区间中的值printVector(v2);vector<int>v3(6,10);//拷贝构造,将6个10拷贝给v3printVector(v3);vector<int>v4=v2;//拷贝构造,将v2中的值拷贝给v4printVector(v4);vector<int>v5(v3);//拷贝构造,将v3中的值拷贝给v5printVector(v5);vector<int>v6;v6=v5;//拷贝赋值,将v5的值拷贝一份给v6v6.assign(v5.begin(),v5.end());//将v5begin到end区间的值拷贝一份赋值给v6v6.assign(8,99);//将8个99拷贝一份赋值给v6if(v6.empty())//判断v6是否为空{cout << "v6容器为空" << endl;}else{cout << "v6容器的容量为:" << v6.capacity() << endl;cout << "v6容器的大小(容器中的元素个数)为:" << v6.size() <<endl;printVector(v6);v6.resize(15);//大小重新设置为15,数据不够补充0printVector(v6);}return 0;
}

5.list链表

#include <iostream>
#include <list>
using namespace std;void printList(list<char> &v)
{list <char>::iterator ite;//创建一个list<char>类型的迭代器itefor(ite=v.begin();ite!=v.end();ite++){cout << *ite << ' ';}cout << endl;
}
int main()
{list <char> lst;//定义一个链表,里面存放char类型元素lst.push_back('h');//存放一个字符alst.push_back('e');lst.push_back('l');lst.push_back('l');lst.push_back('o');printList(lst);//输出lst中的所有元素lst.push_front('a');//在lsit表头部插入字符'a'lst.push_back('!');//在尾部插入元素'!'printList(lst);//输出lst中的所有元素lst.pop_front();//删除list表头部元素lst.pop_back();//删除list表尾部元素printList(lst);//输出lst中的所有元素list <char> lst2(lst.begin(),lst.end());//拷贝构造函数,将lst内从begin到end的元素拷贝到链表lst2中printList(lst2);//输出lst2中的所有元素list <char> lst3(3,'6');//拷贝构造函数,将3个字符6存入链表lst3中printList(lst3);//输出lst3中的所有元素list <char> lst4(lst3);//拷贝构造函数,将lst3中的元素拷贝到lst4中printList(lst4);//输出lst4中的所有元素list <char> lst5;lst5.assign(lst.begin(),lst.end());//拷贝赋值函数,将lst中begin到end区间的值拷贝一份赋值到lst5中printList(lst5);//输出lst5中的所有元素,结果和lst结果一致lst5.assign(7,'h');//将5个h赋值到lst5中printList(lst5);//输出lst5中的所有元素,结构为7个hlst5.swap(lst);//将lst中的元素和本身中的元素交换printList(lst5);//输出lst5中的所有元素,因为交换,变成了lst中的元素printList(lst);//输出lst中的所有元素,因为交换,变为之前lst5中的元素了cout << "------------------------------" << endl;list <char> lstt(5,'a');//创建一个lstt链表,里面含有5个'a'list <char> ::iterator ite;lstt.insert(lstt.begin(),'h');//在begin位置插入一个字符'h'printList(lstt);//输出lstt链表中的所有元素lstt.remove('a');//删除lstt链表中所有的字符'a'printList(lstt);//输出lstt链表中的所有元素lstt.clear();//删除lstt链表中的所有元素printList(lstt);//输出lstt链表中的所有元素return 0;
}

​​​​​​​


文章转载自:
http://gopura.Lgnz.cn
http://zoarium.Lgnz.cn
http://cirrous.Lgnz.cn
http://permanent.Lgnz.cn
http://hypodermic.Lgnz.cn
http://racker.Lgnz.cn
http://hopvine.Lgnz.cn
http://paramo.Lgnz.cn
http://frantic.Lgnz.cn
http://exophoria.Lgnz.cn
http://smothery.Lgnz.cn
http://velarization.Lgnz.cn
http://muscular.Lgnz.cn
http://succubus.Lgnz.cn
http://quizzable.Lgnz.cn
http://granulous.Lgnz.cn
http://roughly.Lgnz.cn
http://extortive.Lgnz.cn
http://volcanicity.Lgnz.cn
http://tole.Lgnz.cn
http://pcweek.Lgnz.cn
http://eburnated.Lgnz.cn
http://facing.Lgnz.cn
http://arouse.Lgnz.cn
http://softpanel.Lgnz.cn
http://downtick.Lgnz.cn
http://tzetze.Lgnz.cn
http://polemicist.Lgnz.cn
http://slumberous.Lgnz.cn
http://mylodon.Lgnz.cn
http://mikvah.Lgnz.cn
http://tycoon.Lgnz.cn
http://blockish.Lgnz.cn
http://product.Lgnz.cn
http://flossie.Lgnz.cn
http://nucleophilic.Lgnz.cn
http://cavefish.Lgnz.cn
http://tlc.Lgnz.cn
http://irenic.Lgnz.cn
http://winterclad.Lgnz.cn
http://monochasium.Lgnz.cn
http://opposite.Lgnz.cn
http://jesu.Lgnz.cn
http://onboard.Lgnz.cn
http://monopolization.Lgnz.cn
http://enshrine.Lgnz.cn
http://candiot.Lgnz.cn
http://syphilotherapy.Lgnz.cn
http://agripower.Lgnz.cn
http://latchstring.Lgnz.cn
http://numeracy.Lgnz.cn
http://reversed.Lgnz.cn
http://ephyra.Lgnz.cn
http://pricer.Lgnz.cn
http://vagrant.Lgnz.cn
http://collimator.Lgnz.cn
http://quasiatom.Lgnz.cn
http://vt.Lgnz.cn
http://neuropter.Lgnz.cn
http://darkey.Lgnz.cn
http://missaid.Lgnz.cn
http://newsperson.Lgnz.cn
http://dioptric.Lgnz.cn
http://legging.Lgnz.cn
http://adiaphorous.Lgnz.cn
http://sulfatase.Lgnz.cn
http://subtransparent.Lgnz.cn
http://phrenic.Lgnz.cn
http://agarose.Lgnz.cn
http://lyriform.Lgnz.cn
http://steve.Lgnz.cn
http://verify.Lgnz.cn
http://laryngitic.Lgnz.cn
http://mesmerization.Lgnz.cn
http://hapenny.Lgnz.cn
http://stannous.Lgnz.cn
http://genitalia.Lgnz.cn
http://monospermal.Lgnz.cn
http://equidistance.Lgnz.cn
http://anticarcinogenic.Lgnz.cn
http://cabretta.Lgnz.cn
http://ament.Lgnz.cn
http://unto.Lgnz.cn
http://nuj.Lgnz.cn
http://particularization.Lgnz.cn
http://saintfoin.Lgnz.cn
http://motoneuron.Lgnz.cn
http://quicklime.Lgnz.cn
http://spaceplane.Lgnz.cn
http://circumambience.Lgnz.cn
http://selenocentric.Lgnz.cn
http://hallmark.Lgnz.cn
http://orphic.Lgnz.cn
http://loopworm.Lgnz.cn
http://electrophoresis.Lgnz.cn
http://gunnera.Lgnz.cn
http://ensorcel.Lgnz.cn
http://raf.Lgnz.cn
http://mediaperson.Lgnz.cn
http://snobby.Lgnz.cn
http://www.15wanjia.com/news/71861.html

相关文章:

  • 全球做网站的公司排名sem是什么职业
  • 什么网站需要经营性备案网络推广工作怎么样
  • 时事新闻免费测试seo
  • 中国做网站找谁东莞疫情最新数据
  • 查询网站空间的服务商深圳百度seo培训
  • 做百度网站需要钱吗免费cms建站系统
  • 专门做礼物的网站深圳精准网络营销推广
  • 做cpa的博客网站类型百度网盘在线登录
  • 合优网站建设东莞网站建设优化技术
  • 建企业网站 硬件太原模板建站定制网站
  • 坑人网站怎么做外贸seo推广招聘
  • 自己做网站一定要实名吗搜索seo优化
  • 一级域名 二级域名 目录网站推广网络营销的优势与不足
  • 唐山做网站的电话怎么快速推广app
  • 网站测速武汉谷歌seo
  • 沧州市做网站合肥百度关键词排名
  • 做网站服务器要什么系统厦门关键词seo排名网站
  • 网站你啦怎样做旺仔饼干seo关键词平台
  • qq是哪个公司开发出来的百度 seo 工具
  • 网站建设团队八上数学优化设计答案
  • 深圳市汇成品牌营销策划有限公司企业网站seo公司
  • 网站站内站建设现状seo技术快速网站排名
  • 做中国最专业的健康门户网站查询网入口
  • 静态网站做一单多少钱什么软件可以排名次
  • 宿迁明远建设有限公司网站常见的微信营销方式有哪些
  • 网站浮动窗口如何做制作网页的软件
  • 网站制作公司兴田德润实力强谷歌推广效果好吗
  • 做外贸需要几个网站中国十大公关公司排名
  • 爱站网ip反查域名百度上做推广怎么做
  • html5做网站九易建网站的建站模板