首页/ 题库 / [单选题]有以下程序: #include <ios的答案

有以下程序: #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy (baseName, "Base"); } virtual char *myName() {

单选题
2023-03-06 06:55
A、DerivedBase
B、BaseBase
C、DerivedDerived
D、BaseDerived
查看答案

正确答案
A

试题解析
解析:本题考核虚函数的应用。类Derived是从基类Base公有派生而来的。因此,Derived是基类Base的子类型。主函数中定义了一个基类对象bb和一个派生类对象dd。从程序中可看出,派生类Derived的对象dd交给了处理基类Base的对象的函数showPtr进行处理。由于在基类中函数myName被定义成虚函数,所以在函数showPtr中调用的myName函数为派生类的成员函数mySame,从而输出Derived。然后输出className,即基类名称Base。

标签:
感兴趣题目
有如下程序: #include <iostream> using namespace std; int main() { int *p; *p = 9; cout << "The value at p: " << *p; return 0; } 编译运行程序将出现的情况是( )。
有如下程序: #include <iostream> using namespace std; int main( ){ int*P; *P=9; cout<<"The value at P:"<<*P: return 0; } 编译运行程序将出现的情况是
有如下程序: #include<iostream> using namespace std; int main() { int *p; *p=9; cout<<"The value at p:"<<*p; return 0; } 编译运行程序将出现的情况是( )
有以下程序: #include 〈iostream〉 using namespace std; #define M 10 #define B4 void setstar(char *a, int n) { int i; for (i=0; i
有以下程序: #include<iostream> using namespace std; int main() { int x=15; while(x>10&&x<50) { x++; if(x/3) { x++;break; } } cout<<x<<endl; return 0; } 执行后的输出结果是( )。
有以下程序: #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy (baseName, "Base"); } virtual char *myName() {
有以下程序:
#include<stdio.h>
#include<string.h>
main(  )
{printf{"%d",strlen("%d",strlen("ATS0121"));}   
程序运行后的输出结果是(  )。
有以下程序: #include <stdio.h> #include <string.h> main() { char str[][20]={"Hello","Beijing"},*P=str[0]; printf("%d ",strlen(p+20)); } 程序运行后的输出结果是( )。
以下程序: #include<stdio.h> #include<string.h> main() {char str[]="abcd 123xab"; printf("%d",(str)); } 运行后的输出结果是( )。
以下程序的输出结果是 #include<iostream.h> void main( ) { int a=21,b=11; cout<<- -a+b;}
以下程序的输出结果是 #include<iostream.h> void main( ) { char x=040; cout < < (X < < 1) ;}
以下程序的输出结果是 #include<iostream.h> void main() { char x=040; cout<<(x<<1);}
相关题目
有如下程序: #include <iostream> using namespace std; class AA { public: virtual void f() { cout<< "AA"; } }; class BB : public AA { public: BB() { cout << "BB"; } }; cla
下面程序的输出结果是( )。 #include<iostream> using namespace std; void main() { int a=18; int * p=&a; cout<<* p;}
有以下程序: #include<string.h> main() { char str[][20]={"Hello","Beijing"),*p=str[0]; printf("%d ",strlen(p+20)); } 程序运行后的输出结果是( )。
若有以下程序: #include <iostream> using namespace std; class point { private: int x, y; public: point ( ) { x=0; y=0; } void setpoint(int x1,int y1) { x=x1; y=y1;
有如下程序: #include <iostream> using namespace std; Class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<
有如下程序: #include <iostream> using namespace std; class AA { public: virtual void f() { cout<< "AA"; } }; class BB : public AA { public: BB() { cout << "BB"; } }; cla
有如下程序: #include<iostream>#include<iosream> using namespace std; class BASE{ char c; public; BASE(char n):c(n){} virtual ~ BASE(){cout<<c;} }; class DERIVED; public BASE{ char c; public: DERIVED (char n): BASE (n+1)
下面程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; } A) B)C) D)
下列程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; }
有以下程序: #include <iostream> using namespace std; char *x[]={"First", "Second", "Third" }; void f(char *z[ ]) { cout<<*z++<<end1; } int main ( ) { char **y; y=x; f(y); return 0; }
有以下程序,程序运行的结果是 ______。 #include<iostream.h> #include<string.h> void main(){ char x[]= "C++" ,y[10]= "C++" ; cout<<sizeof(x)/sizeof(char)<<“,”<<sizeof(y)/sizeof(char); }
当执行下面的程序时,如果输入ABC,输出结果是 ______。 #include<iostream.h> #include<string.h> void main(){ char ss[10]=“XYZWV”; cin>>ss; strcat(ss,”DEFG”); cout<<ss; }
有以下程序:#include #include main(){ char a[20]=ab,b[20]=cdef; int k=0; strcat(a,b); while(a[k]!='\0') {  b[k]=a[k];  k++; } puts(b);}程序的运行结果是(  )。
有以下程序:#include#includemain(){ char w[20],a[5][10]={abcdef,ghijkl,mnopq,rstuv,wxyz.}; int i; for(i=0;i<5;i++)w[i]=a[i][strlen(a[i])-1]; w[5]='\0'; puts(w);}程序的运行结果是(  )。
有以下程序: #include <iostream> using namespace std; class BASE { private: char c; public: BASE(char n):c(n);{} virtual~BASE() { cout<<c; } }; class DERIVED:public BASE { char c; p
有以下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample (int i) { n=i; } static void add() { s+=n; } }; int sample::n=0;
有以下程序:#include #include #include main(){ char*p1,*p2; p1=p2=(char*)malloc(sizeof(char)*10); strcpy(p1,malloc); strcpy(p2,p1+1); printf(%c%c, p1[0], p2[0]);}程序的运行结果是(  )。
下面程序的输出结果是( )。 #include <iostream> using namespace std; void main( ) { int i=8,*p=0; p = &i; coat<<p; }
有下列的程序: #include<cstring.h> #include<iostream.h> using namespace std; class MyString { public: MyString(const char*s); ~MyString()<delete[]data;} protected: unsigned len; char*data; };
有以下程序: #include <iostream> #include <string> using namespace std; int main () { char s[]=" 123\"; cout<<strlen (s) <<", "<<sizeof (s) <<end1; return 0; }
广告位招租WX:84302438

免费的网站请分享给朋友吧