有以下程序:
include <iostream>
using namespace std;
class CFactorial
{
private:
int value;
int fact;
public:
CFactorial ( int val );
void CalculateFactorial();
void Display();
};
CFactorial :: CFactorial( int val )
{
value = val;
fact = 1;
}
void CFactorial :: CalculateFactorial()
{
int i = value;
while ( i > 1 )
fact *= i--;
}
void CFactorial :: Display()
{
cout<<value<<"!="<<fact<<end1;
}
int main()
{
CFactorial A( 5 );
A.CalculateFactorial();
A.Display();
return 0;
}
程序中,类CPactorial的功能是【 】,该程序运行的结果是【 】。
第1题:
有以下程序: #include<iostream> #include<math> using namespace std; class point { private: double x; double y; public: point(double a,double B) { x=a; y=b; } friend double distance (point a,point B) ;
A.1
B.5
C.4
D.6
第2题:
以下程序执行后输出的结果是【 】。
include<iostream>
using namespace std;
int fac(int a,int b){
return(b-a)*a;
}
int main(){
int x=3,y=4,z=5,result;
result=fac(fac(x,y),fac(x,z));
cout<<result<<endl;
return 0;
}
第3题:
若有以下程序: #include <iost ream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<", "; } }; class B { private:
A.10,10,10
B.10,12,14
C.8,10,12
D.8,12,10
第4题:
有以下程序: #include <iostream> using namespace std; class BASE { private: char c; public: BASE(char n):c(n);{} virtual~BASE() { cout<<c; } }; class DERIVED:public BASE { char c; p
A.XY
B.YX
C.X
D.Y
第5题:
有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; }
A.314
B.157
C.78.5
D.153.86