更多"下列程序的输出结果为2,请将程序补充完整。
#include<io"的相关试题:
[填空题]下列程序的输出结果为2,请将程序补充完整。
#include<iostream>
using namespace std;
class Basc
{
public:
【12】 void fun( ){cout<<1;}
};
class Dcrived:public Base
{
public:
void fun( ){cout<<2;}
};
int main( )
{
Base*p=new Derived;
p->fun( );
delete p;
return 0;
}
[填空题]下列程序的输出结果为2,请将程序补充完整。
#include<iostream>
using namespace std;
class Base
public:
______void fun( )cout<<1;
;
class Derived:public Base
public:
void fun( )cout<<2;
;
int main( )
Base*p=new Derived;
p->fur( );
delete p;
return 0;
[填空题]请将下列程序补充完整,使得输出结果为bbaa。
#include<iostream>
using namespace std;
class A
public:
______cout<<"aa";
;
class B:public A
public:
~B( )cout<<"bb";
;
int main( )
B *p=new B;
delete p;
return 0;
[填空题]下列程序输出结果为:
#include<iostream>
using namespace std;
class TestClass1
public:
TestClass1( )
TestClass1(int i)
x1=i;
void dispa( )
cout<<"x1="<<x1<<",";
private:
int x1;
;
class TestClass2:public TestClass1
public:
TestClass2( )
TestClass2(int i):TestClass1(i+10)
x2=i;
void dispb( )
dispa( );
cout<<"x2="<<x2<<endl;
private:
int x2;
;
int main( )
TestClass2 b(2);
b.dispb( );
return 0;
[填空题]下列程序输出结果是 【13】 。
include <iostream>
using namespace std;
template <typename T>
T fun(T a, T b) return (a<=b)a:b;
int main( )
cout<<fun(3,6)<<’,’<<fim(3.14F, 6.28F)<<end 1;
return 0;
[单项选择]下列程序的输出结果是
#include <iostream>
using namespace std;
int main ( )
char a[] = "Hello,World":
char*ptr = a;
while (*ptr)
if(*ptr>= ’a’ &&*ptr <=’z’
cout<<char*ptr+’A’-’a’);
else cout<<*ptr;
ptr++;
return 0;
A. HELLO. WORLD
B. Hello, World
C. hELLO, wORLD
D. hello, world
[单项选择]如下程序的输出结果是
#include<iostream>
using namespace std;
class A
public:
virtual void f( )tout<<1;
void g( )cout<<2;
;
class B:public A
public:
virtual void f( )cout<<3;
void g( )cout<<4;
;
void show(A&
A. f( );a.g( );
B. ;
C. 14
D. 32
[单项选择]下列程序的输出结果是 #include" iostream" using namespace std; int Max(int a,int b) { if(a > b) else return a; else retum b; } void main( ) { int m,n; m=10,n=5; int max=Max(m,n); cout < < max < < end1; }
A. 10
B. 程序有误
C. 1
D. 0
[单项选择]下列程序的输出结果是 #include"iostream" using namespace std; int Max(int a,int b) { if(a>b) return a; else return b; } void main( ) { int m,n; m=10,n=5; int max = Max(m,n); cout<<max<<endl; }
A. 10
B. 程序有误
C. 1
D. 0