题目内容

如下程序声明了一个二维图形类TwoDShape,从其派生出矩形类Rec。 #include<iostream> #include<string> using namespaee std, class TwoDShape{// 二维图形类 char name[20]; public: TwoDShape (char * n="unknown") { strcpy(name, n); } Char * getName(){return name;} =0; }; class Rec: public TwoDShape{ double width, height public: Rec(double w-=0. 0,double h=0. 0):TwoDShape("rectangle") { width=w; height=h; } double getWidth() {return width;} double getHeight() {return height;} double area() {return width * height;} }; int main() { TwoDShape * shape; Shape=new Rec(2.1,3.0); cout<<"object is"<<shape->getName()<<"\n"; cout<<"Area is"<<shape->area()<<"\n"; return 0 } 请将程序补充完整,使程序在运行时输出: abject is triangle Area is 6.3

查看答案
更多问题

关于乳牙根吸收,下列哪种描述是正确的

A. 乳牙根只发生病理性吸收
B. 乳牙根是人体中惟一能发生病理性吸收、消失的硬组织
C. 乳牙替换期的牙根吸收是一种病理性吸收
D. 乳牙的根吸收呈持续性
E. 乳牙根的吸收呈间断性,有活动期和静止期

有以下程序: #include<iostream.h> class A { int x; public: A(int a) { x=a; } friend class B; } class B{ public: void print(A a){ a. x--; cout<<a.x<<end1; } }; void main() { A a(10); B b; b.print(a) ; }程序执行后的输出结果是 。

在C++类中,默认的数据成员的访问权限是 。

对象还有操作,用于改变对象的状态,对象及其操作就是对象的 。

答案查题题库