更多"请在下列程序中的横线处填写正确的语句。
#include<iost"的相关试题:
[填空题]请在下列程序中的横线处填写正确的语句。
#include<iostream>
using namespace std;
class Base
public:
void fun( )cout<<“Basefun”<<endl;
);
class Derivde:public Base
public:
void fun( )
//调用基类的函数fun( )
cout<<“Derived fun”<<endl;
;
[填空题]请在下列程序的横线处填写正确的语句。
#include<iostream>
using namespace std;
class Base{
public:
void fun( ){cout<<"Base fun"<<endl;}
};
class Derivde:public Base{
public:
void fun( ){
______∥ 调用基类的函数fun( )
cout<<"Derived fun"<<endl;
}
};
[单项选择]下列程序中横线处正确的语句是( )。
#include<iostream>
using namespace std;
class TestClass
public:
void fun( )cout<<"TestClass::fun"<<end1;
;
class TestClass1:public TestClass
void fun( )
______//显示调用基类的函数 fun( )
cout<<"TestClass1::fun"<<end1;
;
A. fun();
B. TestClass.fun()
C. TestClass::fun();
D. TestClass->fun();
[填空题]请在如下程序中的空格处填写正确的语句;
#include<iostream>
using namespaee std;
c]ass Base
public:
void fun( )cout<<"Base fun"<<endl;
;
class Derived:public Base
public:
void fun( )
______//调用基类的函数fun( )
cout<<"Derived fun"<<endl;
;
[填空题]在下面程序的横线处填上适当的语句,使该程序的输出为12。
#include <iostream>
using namespace std;
class Base
{
public:
int a;
Base(int i){a=i;}
};
class Derived: public Base
{
int a;
public:
Derived(int x): Base(x),b(x+l){}
void show( )
{
【11】 ;∥输出基类数据成员a的值。
cout<<b<<end1;
}
};
int main( )
{
Derived d(1);
d.show( );
return 0;
}
[填空题]在下面的程序的横线处填上适当的语句,使该程序的输出为12。
#include 〈iostream〉
using namespace std;
class Base
public:
int a;
Base(int i) a=i;
;
class Derived : public Base
int a;
public:
Derived(int x) : Base(x),b(x+1)
void show( )
______; //输出基类数据成员a的值
cout〈〈b〈〈end1;
;
int main( )
Derived d(1);
d.show( );
return 0;
[填空题]在下面的程序的横线处填上适当的语句,是该程序的输出为12。
#include<iostream>
using namespace std;
class Base
public:
int a;
Base(int i)a=i;
;
class Derived:public Base
int a;
public:
Derived(int x):Base(x),b(x+1)
void show( )
【11】 ; //输出基类数据成员a的值。
cout<<b<<endl;
;
int main( )
Derived d(1);
d.show( );
return 0;
[填空题]在下列的程序的横线处填上适当的语句,使该程序的输出为12。
#include<iostream>
using namespace std;
class TestClass
public:
int a,b;
TestClass(int i,int j)
a=i;
b=j;
;
class TestClass1:public TestClass
int a;
public:
TestClass1(int x):TestClass(x,x+1)
void show( )
______;//输出基类数据成员a的值
cout<<b<<endl;
;
int main( )
TestClass1 d(1);
d.show( );
return 0;
[填空题]在下列的程序的横线处填上适当的语句,使该程序的输出为12。
#include<iostream.h>
using namespace std;
class Base
public:
int a,b;
Base(int i)a=i;
;
class Derived:public Base
int a;
public:
Derived(int x):Base(x),b(x+1);
void show( )
______;//输出基类数据成员a的值。
cout<<b<<endl;
;
void main( )
Derived d(1);
d.show( );
return 0;
[简答题]下面程序的功能是输出字符串“HGPEDCBA”, 请在程序的每条横线处填写一个适当的语句,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
import java.io.*;
public class InputString
public static void main(String args[ ])
String stringname= new _______________ ("ABCDEFGH");
for(int i= _______________ i>=0;i--)
System.out.println(String.valueOf(stringname.________________));
[单项选择]下列程序的输出结果为2,横线处应添加语句( )。
#include<iostream>
using namespace std;
public:
______void fun( )cout<<1;
;
class TestClass2:public TestClass1
public:void fun( )cout<<2;)
;
int main( )
TestClass1 *p=new TestClass2;
p->fun( );
delete p;
Teturn 0;
A. public
B. private
C. virtual
D. protected
[单项选择]下列程序中划线处正确的语句是( )。 # include <iostream> using namespace std; class Base { public: void fun( ){cout<<"Base:: fun" <<endl;} }; class Derived:public Base { void fun( ) { ______ ∥显式调用基类的函数fun( ) cout<<"Derived:: fun"<<endl; } };
A. fun();
B. Basfun();
C. Base::fun();
D. Base- >fun();