首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
如果不使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基类继承的成员。有如下程序,没有使用多态机制: #include <iostream> using namespace std; class Base{
如果不使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基类继承的成员。有如下程序,没有使用多态机制: #include <iostream> using namespace std; class Base{
admin
2012-04-29
42
问题
如果不使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基类继承的成员。有如下程序,没有使用多态机制:
#include <iostream>
using namespace std;
class Base{
int a,b;
public:
Base(int x,inty){a=x;b=y;}
void show( ){cout<<a<<’,’<<b<<endl;}
};
class Derived:public Base{
int C,d;
public:
Derived(int x,int y,int z,intm):Base(x,y){c=z;d=m;}
void show( ){cout<<c<<’,’<<d<<endl;}
}.
int main( ){
Base BI(50,50),*pb;
Derived D1(10,20,30,40);
pb=&D1;
pb->show( );
return 0;
}
程序的输出结果是
A) 10,20
B) 30,40
C) 20,30
D) 50,50
选项
A、
B、
C、
D、
答案
A
解析
转载请注明原文地址:https://jikaoti.com/ti/stL0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下关于逻辑运算符两侧运算对象的叙述中正确的是()。
若有以下定义,则对数组元素的正确引用是()。inta[5],*p=a;
某二叉树共有730个结点,其中度为1的结点有30个,则叶子结点个数为()。
若有定义语句:intx=12,y=8,z;在其后执行语句:z=0.9+x/y:则z的值为()。
以下选项中叙述正确的是()。
有以下程序:#include<stdio.h>main(){charb,c;inti;b=’a’;c=’A’;for(i=0;i<6;i++){if(i%2)putchar(i+b);elseputchar(i+c);}pr
设有如下的程序段:charstr[]=“HelloWorld”;char*ptr;ptr==str;执行上面的程序段后,*(ptr+10)的值为()。
设变量均已正确定义,若要通过scanf("%d%c%d%c",&a1,&c1,&a2,&c2);语句为变量a1和a2赋数值10和20,为变量c1和c2赋字符X和Y。以下所示的输入形式中正确的是(注:□代表空格字符)
定义无符号整数类为UInt,下面可以作为类UInt实例化值的是()。
当+运算符被重载为友元函数时,友元运算符Obj1+obj2被C++编译器解释为______。
随机试题
ABC集团公司是XYZ会计师事务所的常年审计客户,上年度各项内部控制设计合理并运行有效。X注册会计师正在对ABC集团公司本年度的内部控制进行了解,并评估重大错报风险。ABC集团公司有20余家子公司。2013年初,为了满足集团公司对财务信息实时性、准确性、真
下述关于多烯磷脂酰胆碱的描述,正确的有
独立董事的产生由( )决定。
甲公司应付乙公司账款90万元,由于发生严重财务困难,甲公司无法偿还欠款,与乙公司达成债务重组协议,甲公司以一台设备抵偿债务。该设备的账面原价为120万元,已提折旧30万元,已提减值准备10万元,公允价值为65万元,甲公司因该项债务重组业务对损益的影响金额为
从投资的功能上可以将投资动机划分为( )。
一般来说,认知风格中场依存性者更感兴趣的学科是()。
科学家对发掘于埃塞俄比亚哈达尔遗址的南方古猿足骨的第4根跖骨化石进行分析研究后发现,非洲南方古猿具有定型的弓形足。他们据此认为,人类的祖先早在320万年前就开始像现代人一样用双脚行走。以下哪项如果为真,最能支持上述论证?
(2003年试题,三)过坐标原点作曲线y=lnx的切线,该切线与曲线y=lnx及x轴围成平面图形D(见图1一3—5).求D的面积A;
设有下列二叉树:对此二叉树中序遍历的结果为______。
Youaregoingtowriteabout200wordsonthefollowingtopic"Whatwillhappenwhenone’smothertongueislost’.Youarerequi
最新回复
(
0
)