C 程序写运行结果。class A{public:void f1(){printf("A::f1\r\n");}virtual void f2(){printf("A::f2\r\n");}void callfunc(){printf("A::callfunc\r\n");f1();f2();}};class B :public A{public:void f1(){printf("B::f1\r\n");}void f2(){printf("B::f2\r\n");}void callfunc(){printf("B::callfunc\r\n");f1();f2();}};int main(){B *pB=new B;pB-callfunc();A *pA=pB;pA-callfunc();return 0;}

C 程序写运行结果。

class A

{

public:

void f1()

{

printf("A::f1\r\n");

}

virtual void f2()

{

printf("A::f2\r\n");

}

void callfunc()

{

printf("A::callfunc\r\n");

f1();

f2();

}

};

class B :public A

{

public:

void f1()

{

printf("B::f1\r\n");

}

void f2()

{

printf("B::f2\r\n");

}

void callfunc()

{

printf("B::callfunc\r\n");

f1();

f2();

}

};

int main()

{

B *pB=new B;

pB->callfunc();

A *pA=pB;

pA->callfunc();

return 0;

}


相关考题:

有以下程序#include stdio.hmain(){ int f,f1,f2,i;f1=0;f2=1;printf("%d %d ",f1,f2);for(i=3;i=5;i++){ f=f1+f2; printf("%d",f);f1=f2; f2=f;}printf("\n");}程序运行后的输出结果是 【 1 0 】 。

下面程序的输出结果是 ( ) main( ) { int i,f1,f2; f1=f2=1; for(i=0;i<4;i+ +) { printf(”%d%d”,f1,f2); f1+ =f2; f2+ =f1; } }A.1 2 3 4 5 6 7 8B.1 1 2 3 5 8 13 21C.1 1 3 5 7 9 11 13D.1 3 5 7 9 11 13 15

下列程序的运行结果是【 】。 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()}

请写出下面的输出:class B{public:virtual void Print(void){printf(“B::Print\n”);}virtual void Reprint(void){printf(“B:Reprint\n”);}void Algo(void){Print();Reprint();}};class D : public B{public:virtual void Print(void){printf(“D::Print\n”);}};void main(){B *p = new D();p-Print();p-Algo();}

以下程序的运行结果为______。main(){ int i,f1,f2; f1=f2=1; for(i=0;i<4;i++) { printf("%d %d",f1,f2); f1+=f2; f2+=f1; }}A.1 1 2 3 5 8 13 21B.1 1 2 2 5 5 10 10C.1 2 5 8 9 8 13 21D.0 1 1 2 4 5 15 21

有以下程序: int fa(int x) { return x*x; } int fb(int x) { return x*x*x; } int f(int (*f1)(),int (* f2)(),int x) { return (*f2)(x)-(*f1)(x); } main() { int i; i=f(fa,fb,2); printf("%d\n",i); } 程序运行后的输出结果是( )A.-4B.1C.4D.8

以下程序的输出结果是( )。 include void main() {int f,f1,f2,i; f1=0;f2=1; printf("% 以下程序的输出结果是( )。 include<stdio.h> void main() {int f,f1,f2,i; f1=0;f2=1; printf("%d%d",f1,f2); for(i=3;i<=5;i++) {f=-f1+f2,printf("%d",f); f2=f1;f1=f; } printf("\n"); }

设f1,f2是条件表达式,σf1(σf2(R))等价于_______。A.σf1∧f2(R)B.σf1Úf2(R)C.σf2(R)D.σf1(R)

下面程序的输出结果是: def fib(n): f1, f2 = 0, 1 while f2 < n: print f2, f1, f2 = f2, f1 + f2 fib(10)