实验内容
1.//sy_3.1cpp正确程序如下“
//sy3_1.cpp
include
using namespace std;
class Aa
{
public:
Aa(int i=0){a=i;cout<<”Constructor”<
include
using namespace std;
class TPoint
{
public:
TPoint(int x=0,int y=0){X=x,Y=y;}
TPoint(TPoint &p);
~TPoint(){cout<<”Destructor is called\n”;}
int getx(){return X;}
int gety(){return Y;}
private:
int X,Y;
};
TPoint::TPoint(TPoint &p)
{
X=p.X;
Y=p.Y;
cout<<”Constructor is called\n”;
cout<<”Copy-initialization Constructor is called\n”;
}
int main()
{
TPoint p1(4,9);
TPoint p2(p1);
TPoint p3=p2;
TPoint p4,p5(2);
cout<<”p3=(“<
include
using namespace std;
class Heapclass
{
public:
Heapclass(int x);
Heapclass();
~Heapclass();
private:
int i;
};
Heapclass::Heapclass(int x)
{
i=x;
cout<<”Contstructor is called. “<
include
using namespace std;
class Rectangle
{
public:
Rectangle(){len=0;wid=0;}
Rectangle(double Len,double Wid){len=Len;wid=Wid;}
double Circumference(){return 2*(len+wid);}
double Area(){return len*wid;}
double getl(){return len;}
double getw(){return wid;}
void charge(double a,double b){len=a;wid=b;}
printf()
{
cout<<”length:”<