更多"在下面程序的下划线处填上正确的语句。 &nbs"的相关试题:
[填空题]以下程序的功能是用递归法求n!,请在下划线处填上正确的语句,使程序能正确运行。
#include
long f(int n)
{
if(n==1)return(________);
else return (________________);
}
main( )
{
int n;
printf("n=");
scanf("%d",&n);
printf("%d!=%ld",n,f(n));
}
[简答题]在下划线处填上缺少的部分。
#include<iostream.h>
class A
int a,b;
public:
______//定义构造函数,使参数i和j的默认值为0
a=i;b=j;//在函数体中用i初始化a,用j初始化b
;
main( )
A*p;
______;//调用带参构造函数生成由p指向的动态对象
//使a和b成员分别被初始化为4和5
[填空题]在下面横线上填上适当的语句,完成程序。
#include <iostream>
using namespace std;
class Base
{
int x;
public:
Base(int i){ x=i;}
~Base( ){}
};
class Derived : public Base
{
public:
______//完成类Derive构造函数的定义
};
int main( )
{
Derived Obj;
return 0;
}
在横线处应填入的语句是______。
[填空题]在下面横线上填上适当的语句,完成程序。
#include<iostream>
using namespace std;
class TestClass
int x;
public:
TestClass(int i)x=i;
~TestClass( )
;
class TestClass1:public TestClass
public;
______//完成类TestClassl构造函数的定义
;
int main( )
TestClass1 0bj( );
return 0;
[填空题]在下面横线上填上适当的语句,完成程序。
#include<iostream>
using namespace std;
class Base
{
int x;
public:
Base(int i){x=i;}
~Base( ){}
};
class Derived:public Base
{
public:
___________//完成类Derive构造函数的定义
};
int main( )
{
Derived Obj;
return 0;
}
在横线处应填入的语句是 【9】 。
[填空题]在下面横线上填上适当的语句,完成程序。
#include<iostream>
using namespace std;
class Base int x;
public:
Base(int i) x=i;
~Base( )
;
class Derived: public Basepublic:
【14】 //完成类Derive 构造函数的定义
;
int main( ) Derived Obj( );
return 0;
[填空题]在下面程序的横线处填上适当的语句,使该程序执行结果为10。
#include <iostream>
using namespace std;
class MyClass
{
public:
MyClasS(int A)
{
X=a;
}
【13】 //取x的值
private:
int x;
};
int main( )
{
MyClass my(10);
cout<<my.GetNum( )<<end1;
return 0;
}