C++1022029101Qt1994C++GUIGUI2GCCGNUCCompilerlinuxGCCCGCCGCCCC++AdaObjectCJavaGCCGNUCCompilerGNUCompilerCollectionGNUGCC3MinGWWindowsGCC4QtDesignerGUIQt5Qt/EmbeddedGUILinux6DebugRelease)7Build.exe8C++C(1)C(2)9cincoutIOiostream.h10C++stdioIOprintf()scanf()11412C/C++131415(Message1617.-18/19fstream.h/20C++cincoutcerrclog21C++22ofstreamoutfileoutfile.open(d:\\newfile.datiosout)23Qt2425clickeddoubleclicked26Qtconnect(sender,SIGNAL(signal)receiver;SLOT(slot));27ios::app28qmakeproject.pro29mingw32-make.exe1523035151AABMainWindowCD2C++CABC++CD3BAC++C++BCD4CABCD5CABCD06BABCD7unsignedDAcharBintClongintDfloat8BABCD9ifDABCD10AABCD11deleteCAnewBCD12CABregisterCprivate,protected,publicDprivate,protected,public13AABCD14showCAvirtualshow()=0;Bvirtualvoidshow();Cvirtualvoidshow()=0;Dvoidshow()=0virtual;15DAfriendB)-varC3xyzDFloat16AABCD17AABCD18DABprivateCprotectedDpublic19DABCD20BABCD21C++CABCD22BABCD23DAC++BC++CC++DC++24CABCD25AAfriendBstaticCconstDcolatile26XVoidSet(X&a)X&aCAXaBaSetCaXSet()DXaSet()27newCABDELETECD28AABCD29AABCD30CABCD31DABCD32DABCD33QTBAC++BTrollTechCUnixLinuxDQTVF34QTDAsignalslotBCD35/DAconnectedB/QObjectCQWidgetD1265301261#includeiostreamusingnamespacestd;classArray//{public:voidset_value();voidmax_value();voidshow_value();private:intarray[10];intmax;};voidArray::set_value()//{inti;for(i=0;i10;i++)cinarray[i];}voidArray::max_value()//{inti;max=array[0];for(i=0;i10;i++)if(maxarray[i])max=array[i];}voidArray::show_value()//{coutmax=maxendl;}intmain()//{Arrayarrmax;arrmax.set_value();arrmax.max_value();arrmax.show_value();return0;}09101234567890max=923#includeiostreamusingnamespacestd;longFac(intn)//Facn{inti=1;longf;if(n1)return-1;for(f=1;i=n;i++)f=f*i;returnf;}intmain(){intnum;longfac;cout0;cinnum;fac=Fac(num);//FacnumFacn//nnumf//ffacif(fac==-1)//-1numcout!0\n;else//coutnum!=facendl;}033=63#includeiostream#includestring.husingnamespacestd;intmain(){charname1='liuhewen';cout1name11sizeof(name1)endl;char*name2=lhw;cout2name22sizeof(name2)2strlen(name2)endl;stringname3=liuhewenlhw;cout3name33name3.size()endl;}1n112lhw24233liuhewenlhw3114datesetanddisp.hdatesetanddisp.cppmain.cppdatesetanddisp.h#ifndefDATESETANDDISP_H#defineDATESETANDDISP_HclassDateSetAndDisp{public:DateSetAndDisp(inty=2016,intm=10,intd=19);//~DateSetAndDisp();//DateSetAndDisp(constDateSetAndDisp&d);//voidDateSet(inty,intm,intd);//voidDateDisp();//private:intyear,month,day;//};#endif//DATESETANDDISP_Hdatesetanddisp.cpp#includedatesetanddisp.h#includeiostreamusingnamespacestd;DateSetAndDisp::DateSetAndDisp(inty,intm,intd)//{year=y;month=m;day=d;}//{year=y;month=m;day=d;coutendl;}DateSetAndDisp::~DateSetAndDisp(){coutendl;}DateSetAndDisp::DateSetAndDisp(constDateSetAndDisp&d){year=d.year;month=d.month;day=d.day+1;}//1voidDateSetAndDisp::DateSet(inty,intm,intd){year=y;month=m;day=d;coutendl;}voidDateSetAndDisp::DateDisp(){coutyearmonthdayendl;}main.cpp#includedatesetanddisp.h#includeiostreamusingnamespacestd;intmain(){//DateSetAndDisptoday;//today//today.DateDisp();//DateDisp()today//DateSetAndDisptomorrow(today);//tomorrow1//tomorrow.DateDisp();DateSetAndDispdate[2];//DateSetAndDispdate[0]date[1]date[0].DateDisp();date[1].DateDisp();date[1].DateSet(2016,10,20);date[1].DateDisp();return0;}12016101920161019201610205#includeiostreamusingnamespacestd;classStudent{public:virtualvoidCalculation(){cout\n;}};classGraduateStudent:publicStudent{public:voidCalculation()////{coutendl;}};//FnvoidFn(Student&x)//xStudent{x.Calculation();//x}intmain(){Students;//sGraduateStudentgs;//gs//s.Calculation();//Calculation()//gs.Calculation();//Calculation()//gs.Student::Calculation();//Calculation()Fn(s);//Fn(gs);}6#includeiostreamusingnamespacestd;classComplex{private:doublereal;doubleimag;public:Complex(doublereal=0,doubleimag=0){this-real=real;this-imag=imag;}voidshowC();Complexoperator+(Complexc);friendComplexoperator+(Complexcom1,intx);friendComplexoperator+(intx,Complexcom1);};ComplexComplex::operator+(Complexc){returnComplex(real+c.real,imag+c.imag);}voidComplex::showC(){coutreal;if(imag0)cout+;if(imag!=0)coutimagiendl;}Complexoperator+(Complexcom1,intx){returnComplex(com1.real+x,com1.imag);}Complexoperator+(intx,Complexcom1){returnComplex(x+com1.real,com1.imag);}intmain(){Complexcom1(5,10),com2(10,10),total;total=com1+5;total.showC();total=5+com1;total.showC();total=com1+com2;total.showC();return0;}:10+10i10+10i15+20i7#includeQApplication#includeQLabel#includeQTextCodec//#includeQHBoxLayout//#includeQPushButton//intmain(intargc,char*argv[]){//QApplicationappQApplicationapp(argc,argv);//GBKwindowsQTextCodec*codec=QTextCodec::codecForName(GBK);QTextCodec::setCodecForTr(codec);QTextCodec::setCodecForLocale(codec);QTextCodec::setCodecForCStrings(codec);//QLabellabelQLabel*label=newQLabel(Qt);//textQPushButton*quitButton=newQPushButton();//click()quit()QObject::connect(quitButton,SIGNAL(clicked()),&app,SLOT(quit()));//myWindo