欢迎来到天天文库
浏览记录
ID:15685032
大小:101.00 KB
页数:31页
时间:2018-08-04
《作业及其答案汇总》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、一、类和对象基本概念1)写出下面程序的运行结果:#includeclassApple{private:staticintnTotalNumber;public:Apple(){nTotalNumber++;}~Apple(){nTotalNumber--;}staticvoidPrintTotal(){cout<2、ple[4];Fun(p[2]);Applep1,p2;delete[]p;p1.PrintTotal();}/*41*/2)写出下面程序的运行结果:#includeclassSample{public:intv;Sample(){};Sample(intn):v(n){};Sample(Sample&x){v=2+x.v;}};SamplePrintAndDouble(Sampleo){cout<3、ble(b);cout<4、补足Complex类的成员函数。不能增加成员变量。#include#includeusingnamespacestd;classComplex{private:doubler,i;public:voidPrint(){cout<5、足Sample类的成员函数。不能增加成员变量。#includeclassSample{public:intv;Sample(intn):v(n){};};intmain(){Samplea(5);Sampleb=a;cout<#includeclassMyString{char*p;public:MyString(char6、*s){p=newchar[strlen(s)+1];strcpy(p,s);}~MyString(){delete[]p;}constchar*c_str(){returnp;}};intmain(){MyStrings1("This"),s2=s1;s2.Copy("Hello");cout<7、+1];strcpy(p,o.p);}*/7)下面程序的输出结果是:5,55,5请填空#include#includeclassBase{public:intk;Base(intn):k(n){}};classBig{public:intv;Baseb;Big________________{}Big________________{}};intmain(){Biga1(5);Biga2=a1;cout<
2、ple[4];Fun(p[2]);Applep1,p2;delete[]p;p1.PrintTotal();}/*41*/2)写出下面程序的运行结果:#includeclassSample{public:intv;Sample(){};Sample(intn):v(n){};Sample(Sample&x){v=2+x.v;}};SamplePrintAndDouble(Sampleo){cout<3、ble(b);cout<4、补足Complex类的成员函数。不能增加成员变量。#include#includeusingnamespacestd;classComplex{private:doubler,i;public:voidPrint(){cout<5、足Sample类的成员函数。不能增加成员变量。#includeclassSample{public:intv;Sample(intn):v(n){};};intmain(){Samplea(5);Sampleb=a;cout<#includeclassMyString{char*p;public:MyString(char6、*s){p=newchar[strlen(s)+1];strcpy(p,s);}~MyString(){delete[]p;}constchar*c_str(){returnp;}};intmain(){MyStrings1("This"),s2=s1;s2.Copy("Hello");cout<7、+1];strcpy(p,o.p);}*/7)下面程序的输出结果是:5,55,5请填空#include#includeclassBase{public:intk;Base(intn):k(n){}};classBig{public:intv;Baseb;Big________________{}Big________________{}};intmain(){Biga1(5);Biga2=a1;cout<
3、ble(b);cout<4、补足Complex类的成员函数。不能增加成员变量。#include#includeusingnamespacestd;classComplex{private:doubler,i;public:voidPrint(){cout<5、足Sample类的成员函数。不能增加成员变量。#includeclassSample{public:intv;Sample(intn):v(n){};};intmain(){Samplea(5);Sampleb=a;cout<#includeclassMyString{char*p;public:MyString(char6、*s){p=newchar[strlen(s)+1];strcpy(p,s);}~MyString(){delete[]p;}constchar*c_str(){returnp;}};intmain(){MyStrings1("This"),s2=s1;s2.Copy("Hello");cout<7、+1];strcpy(p,o.p);}*/7)下面程序的输出结果是:5,55,5请填空#include#includeclassBase{public:intk;Base(intn):k(n){}};classBig{public:intv;Baseb;Big________________{}Big________________{}};intmain(){Biga1(5);Biga2=a1;cout<
4、补足Complex类的成员函数。不能增加成员变量。#include#includeusingnamespacestd;classComplex{private:doubler,i;public:voidPrint(){cout<5、足Sample类的成员函数。不能增加成员变量。#includeclassSample{public:intv;Sample(intn):v(n){};};intmain(){Samplea(5);Sampleb=a;cout<#includeclassMyString{char*p;public:MyString(char6、*s){p=newchar[strlen(s)+1];strcpy(p,s);}~MyString(){delete[]p;}constchar*c_str(){returnp;}};intmain(){MyStrings1("This"),s2=s1;s2.Copy("Hello");cout<7、+1];strcpy(p,o.p);}*/7)下面程序的输出结果是:5,55,5请填空#include#includeclassBase{public:intk;Base(intn):k(n){}};classBig{public:intv;Baseb;Big________________{}Big________________{}};intmain(){Biga1(5);Biga2=a1;cout<
5、足Sample类的成员函数。不能增加成员变量。#includeclassSample{public:intv;Sample(intn):v(n){};};intmain(){Samplea(5);Sampleb=a;cout<#includeclassMyString{char*p;public:MyString(char
6、*s){p=newchar[strlen(s)+1];strcpy(p,s);}~MyString(){delete[]p;}constchar*c_str(){returnp;}};intmain(){MyStrings1("This"),s2=s1;s2.Copy("Hello");cout<7、+1];strcpy(p,o.p);}*/7)下面程序的输出结果是:5,55,5请填空#include#includeclassBase{public:intk;Base(intn):k(n){}};classBig{public:intv;Baseb;Big________________{}Big________________{}};intmain(){Biga1(5);Biga2=a1;cout<
7、+1];strcpy(p,o.p);}*/7)下面程序的输出结果是:5,55,5请填空#include#includeclassBase{public:intk;Base(intn):k(n){}};classBig{public:intv;Baseb;Big________________{}Big________________{}};intmain(){Biga1(5);Biga2=a1;cout<
此文档下载收益归作者所有