网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

下列程序运行后的输出结果是( )。#include#includeusing namespace std;class Person{public:Person(string n):name(n) { cout<<'P'; }private:string name;};class Date{public:Date(int y=2012,int m=12,int d=21):year(y),month(m),day(d) { cout<<'D'; }

private:int year,month,day;};class Student:public Person{public:Student(string n,int y,int m,int d,char c):birthday(y,m,d),sex(c),Person(n) { cout<<'S'; }private:Date birthday;char sex;};int main(){Student stu1("Zhang",1990,10,1,'F');return 0}

A. S

B.PS

C.DPS

D.PDS


参考答案

更多 “ 下列程序运行后的输出结果是( )。#include#includeusing namespace std;class Person{public:Person(string n):name(n) { coutprivate:int year,month,day;};class Student:public Person{public:Student(string n,int y,int m,int d,char c):birthday(y,m,d),sex(c),Person(n) { coutA. SB.PSC.DPSD.PDS ” 相关考题
考题 下面程序运行后输出的结果是【】。 include using namespace std; class example{ const 下面程序运行后输出的结果是【 】。include <iostream>using namespace std;class example{const int m;public:example(int i):m(i){}void pr(){cout<<"m="<<m<<endl'}};int main(){example x(100);x.pr();return 0;}

考题 下列程序的运行结果是【 】。 include class SomeClass { public: SomeClass(int va 下列程序的运行结果是【 】。include <iostream. h>class SomeClass{public:SomeClass(int value) { some_value=value;};void show_data(void) { cout<<data<<"<<~some_value<<endl; };static void set_data(int value) {data=value; }private:static int data;int some_value};int SomeClass::datavoid main(void){SomeClass my_class(1001),your_class(2002);your_class. set_data(4004);my_elass. show_data()}

考题 下列程序运行后的输出结果是( )。#includeusing namespace std;class A{public:void f() { coutvirtual void g() { cout};class B : public A {public:void f() { coutvirtual void g() { cout};void show(AA. g();}int main() {B b;show(b);return 0;}A. 13B.14C.23D.24

考题 下列程序的运行结果是______。 include class A { public: virtual void use( ) {cou 下列程序的运行结果是______。include<iostream.h>class A{public:virtual void use( ) {cout<<"in A\n";}};class B:public A{public:virtual void use( ) {cout<<"in B\n";}};class C:public B{public:virtual void use( ){cout"in C\n";}};void main( ){A*obj;bj=new C;obj->use( );delete obj;}

考题 下列程序的运行结果是______。include class Base { public: void f(int x){cout 下列程序的运行结果是______。include<iostream.h>class Base{public:void f(int x){cout<<“Base:”<<x<<endl;});class Derived:public Base{public:void f(char*str){cout<<“Derived:”<<str<<endl;}};void main(void){Base*pd=ne

考题 请将下列程序的横线处补充完整,使得输出结果为bbaaincludeusing namespace std;class 请将下列程序的横线处补充完整,使得输出结果为bbaainclude<iostream>using namespace std;class A{public:______{cout<<"aa";}};class B:public A{public:~B(){cout<<"bb";}};int main(){B*p=new

考题 若有如下程序:#includeiostreamusingnamespaeestd;classTestClass{public:voidwho(){coutTestClassendl;}};classTestClassl:publicTestClass{public:voidwho(){coutTestClasslendl;}};intmain(){TestClass*P;TestClasslobj1;p=&obj1;p-who();retum0;}则该程序运行后的输出结果是( )。A.TestClasslB.TestClassC.0D.无输出

考题 若有如下程序: #includeiostream usingnamespaeestd; classTestClass { public: voidwho(){cout"TestClass"endl;} }; classTestClassl:publicTestClass { public: voidwho(){cout"TestClassl"endl;}}; intmain() { TestClass*P; TestClasslobj1; p=&obj1; p-who(); retum0; } 则该程序运行后的输出结果是( )。A.TestClasslB.TestClassC.0D.无输出

考题 若有以下程序:includeusing namespace.std;class data{public: int x; data (int x) 若有以下程序: #include<iostream> using namespace.std; class data { public: int x; data (int x) { data::x=x; } ); class A { private: data d1; public: A(int x) :dl(X){} void dispa() { cout<<dl.X<<","; } }; class B:public A { private: data d2; public: B(int x) : A(x-1),d2(x){} void dispb() { cout<<d2.x<<endl; } }; class C:public B { public: C(int x) :B(x-1){} void disp() { dispa(); dispb(); } }; int main() { C obj(5); obj.disp(); return 0; } 程序执行后的输出结果是A.5,5B.4,5C.3,4D.4,3