判断说明题(阅读下列程序,判断其有无错误,若有错,请指出错误之处并说明理由;若无错,只需说明该程序正确。)
1 声明类date
class date{
int day;
int month;
int year;
public:
void date(int y,int m,int d);
void ~date(int y,int m,int d);
……………………………………
};
2 #include<iostream.h>
class B
{public:
B(int nb,float fb){n=nb;f=fb;}
B(B &b){n=b.n;f=b.f;}
~B(){}
private:
int n;
float f;
};
void main(){
B b1;
B b2=b1;
}
3 class test
{
private:
static int x=0;
public:
static int fun=();
};
4 #include<iostream>
using namespace std;
class A{
int x;
public:
A(int a):x(a){cout<<”Constructing A\n”;}
};
class B:public A{
public:
B(int a){cout<<”Constructing B\n”;}
}
void main(){
A a(5);
}
5 #include<iostream>
using namespace std;
class Point{
double x; double y;
public:
void set(double ix,double iy){x=ix;y=iy;}
………………………………………
};
void main(){
Point p;
double x,y;
cout<<”Enter x and y:\n”;
cin>>x>>y;
p.set(x,y);
p.x+=5;
p.y+=6;
……………………………………….
}
实在是做不出来 来这里求大家帮我 谢谢。
[此贴子已经被作者于2007-8-11 21:20:02编辑过]