更多"有如下程序:#include <iostream>using name"的相关试题:
[单项选择]有如下程序
#include <iostream>
using namespace std;
class A
public:
virtual void func1 ( ) cout<<"A1";
void func2( ) cout<<"A2";
;
class B: public A
public:
void func l( ) cout<<"B1";
void func2( ) cout<<"B2";
;
int main( )
A *p=new B;
p->func1( );
p->func2( );
return 0;运行此程序,屏幕上将显示输出()。
A. B1B2
B. A1A2
C. B1A2
D. A1B2
[单项选择]有以下程序:
#include <iostream>
using namespace std;
class sampleprivate:
int x;
static int y;
public:
sample(int a);
static void print(sample s);
;
sample:: sample(int a) x=a;
y+=x;void sample:: print(sample s) cout<<"x="<<s. x<<",y="<<y<<end1;int sample:: y=0;
int main( ) sample s1(10);
sample s2(20);
sample:: print(s2);
return 0;程序运行后的输出结果是( )。
A. x=10,y=20
B. x=20,y=30
C. x=30,y=20
D. x=30,y=30
[单项选择]有如下程序
#include <iostream>
using namespace std;
class Base
protected:
Base( )cout<<'A';
Base(char c) cout<<c;
;
class Derived: public Base
public:
Derived(char c) cout<<c;
);
int main( )
Derived dl('B');
return 0;
执行这个程序屏幕上将显示输出( )。
A. B
B. BA
C. AB
D. BB