深圳二手表回收:悬赏100分关于C++的编程,高手指教!在线急等!

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/30 08:16:56
周一前需要以下题的源程序最好可以运行,急!题比较多大家见谅。多谢先。小弟跪拜裸求了!
1、设计一个类,并利用该类进行编程和测试;要求如下:
(1)其类名为:C_Sophomore;
(2)类有两个私有的数据成员x,y皆为int型;
(3)为该类设计三个构造函数:分别是不带参数、带1个参数和带2个参数,并在构造函数中给出相应的提示;
(4)编写一个主函数测试。
2、编写一个程序设计一个栈操作类,包含入栈和出栈成员函数,然后入栈一组数据,出栈并显示出栈顺序。
3、 编一个使用派生类的程序,使一个包含圆和圆柱的几何尺寸的类,它使用内部数据建立几何形状并显示它们的尺寸,面积和体积。
4、 根据Lab4第二小题定义的复数类(C_Complex), 用运算符的重载的形式实现四则运算:
(1) 运算符重载为友元形式;
(2) 运算符重载为成员函数形式;
5、 在基类中定义一个纯虚函数show(),并在派生类中重新定义show(),使得它以各自的进制(即十六进制,十进制,八进制)输出val。
6、 定义日期类,并为该类重载流操作符"<<"及">>",模拟DOS下的日期(yyyy-mm-dd)设置,要求对日期范围进行检查.
7、 以 Point 类为基础,定义椭圆类和矩形类;再通过椭圆类派生出圆类;通过矩形类派生出正方形类;最后编程测试。
lab4的第二小题是:定义一个复数类(C_Complex),能够实现复数的四则运算,并编写相应的测试程序
有答案就成,高手们来看看哦 !

1答:
#include<iostream.h>
class C_Sophomore
{public:
C_Sophomore();
C_Sophomore(int);
C_Sophomore(int,int);
int put_X(){return x;}
int put_Y(){return y;}
protected:
int x,y;
};
C_Sophomore::C_Sophomore()
{cout<<"the function with none of the parameter"<<endl;}
C_Sophomore::C_Sophomore(int i)
{cout<<"the function with a parameter"<<endl;
x=i;
}
C_Sophomore::C_Sophomore(int i,int j)
{cout<<"the function with two parameters : "<<endl;}

void main()
{C_Sophomore m1;
C_Sophomore m2(3);
C_Sophomore m3(4,5);
}

3.答:
#include<iostream.h>
class point
{public:
point(double=0,double=0);
void put_point();
protected:
double x,y;
};
point::point(double i,double j)
{x=i;
y=j;
}
void point::put_point()
{cout<<"the point of the center is:"<<'('<<x<<","<<y<<')'<<endl;}
class circle:public point
{public:
circle(double=0,double=0,double=0);
void put_radius();
void put_area();
protected:
double radius;
};
circle::circle(double r,double i,double j):point(i,j)
{radius=r;}
void circle::put_radius()
{cout<<"the radius of the circle is :"<<radius<<endl;}
void circle::put_area()
{cout<<"the area of the circle is :"<<3.14*radius*radius<<endl;}
class column:public circle
{public:
column(double=0,double=0,double=0,double=0);
void put_area();
void put_volumn();
protected:
double height;
};
column::column(double h,double r,double i,double j):circle(r,i,j)
{height=h;
}
void column::put_area()
{cout<<"the area of the column is :"<<height*2*3.14*radius+2*3.14*radius*radius<<endl;}
void column::put_volumn()
{cout<<"the volumn of the column is :"<<3.14*radius*radius*height<<endl;}
void main()
{circle m(5,1.2,1.0);
column n(4,4,0.2,0.3);
m.put_point();
m.put_radius();
m.put_area();
n.put_point();
n.put_area();
n.put_volumn();
}
第四道”根据Lab4第二小题定义”啥东东;
5答:
#include<iostream.h>
class number
{public:
number(int=0);
virtual void show()=0;
protected:
int val;
};
number::number(int i)
{val=i;}

class output:public number
{public:
output(int=0);
void show();
};
output::output(int i):number(i){}
void output::show()
{cout<<"hex:"<<hex<<val<<endl<<"dec:"<<dec<<val<<endl<<"oct:"<<oct<<val<<endl;}

void main()
{output n(45);
n.show();}

7答:
#include<iostream.h>
class point
{public:
point(double=0,double=0);
void put_point();
protected:
double x,y;
};
point::point(double i,double j)
{x=i;
y=j;}
void point::put_point();
{cout<<"the point of the center is"<<'('<<x<<","<<y<<')'<<endl;}

class ellipse:public point
{public:
ellipse(double=0,double=0,double=0,double=0);
void put_longside();
void put_shortside();
void put_expressions();
protected:
double a,b;
};
ellipse::ellipse(double m,double n,double i,double j):point(i,j)
{a=m;
b=n;
}
void ellipse::put_longside()
{cout<<"the longside of the ellipse is : "<<(a>b?a:b)<<endl;
}
void ellipse::put_shortside()
{cout<<"the shortside of the ellipse is : "<<(a<b?a:b)<<endl;
}
void ellipse::put_expressions()
{cout<<"the shortside of the ellipse is meet to the expressions : x*x/(a*a)+y*y/(b*b)=1 "<<endl;
}

class rectangle:public point
{public:
rectangle(double=0,double=0,double=0,double=0);
void put_longth(){cout<<"the longth of the rectangle is: "<<longth<<endl;}
void put_width(){cout<<"the width of the rectangle is : "<<width<<endl;}
void put_area();
protected:
double longth,width;
};
rectangle::rectangle(double l,double s,double i,double j):point(i,j)
{longth=l;
width=s;
}
void rectangle::area()
{cout<<"the area of the rectangle is : "<<width*longth<<endl;}

class circle:public ellipse
{public:
circle(double=0,double=0,double=0,double=0);
void put_area(double,double);

protected:
double radius;
};
circle::circle(double m,double n,double i,double j):ellipse(m,n,i,j){}
void circle::put_area(a,b)
{if(a==b)
{radius=a;
cout<<"the radius of the circle is :"<<radius<<endl;
cout<<"the area of the circle is : "<<3.14*radius*radius<<endl;}
else cout<<"it is a ellipse.the area is :"<<4*3.14*a*b<<endl;
}

class square:public rectangle
{public:
square(double=0,double=0,double=0,double=0);
void put_area(double,double);
protected:
double side;
};
square::square(double m,double n,double i,double j):rectangle(m,n,i,j){}
void square::put_area(longth,width)
{if(longth==width)
{side=longth;
cout<<"the longth of the square is :"<<side<<endl;
cout<<"the area of the square is :"<<side*side<<endl;}
else cout<<"It is a rectangle. the area is : "<<width*longth<<endl;
}

void main()
{circle c1(2,1,5.0,2.0);
circle c2(1,1,2.0,2.0);
c1.put_point();
c1.put_area();
c2.put_point();
c2.put_area();
square s1(5,4,0.2,0.2);
square s2(6,6,1.0,2.0);
s1.put_point();
s1.put_area();
s2.put_point();
s2.put_area();
}

这一道我暂时没有时间给你调试,里面应会出现问题,不过很容易能解决的

不好意思,不太能帮到你,我是今晚才看到你的题目的,但我自已得做作业,所以有几道没能给你解决,如果是昨晚的话我就能帮你都做完

不清楚,SORRY