高分 请C++ 高手请进

来源:百度知道 编辑:UC知道 时间:2024/05/28 04:29:20
考试题,急用,谢谢了!答好了再送高分
填空
1、完成下面的类定义
class Myclass
{
public:
Myclass( ) { x = 0;}
________int GetNum (________my);
private:
int x;
};
int GetNum(________my)
{
return my,x;
}

2、下面的类定义了拷贝构造函数,请完成该类的定义和实现
class Myclass
{
public:
Myclass(int XX = 0, int yy = 0){X = xx; Y = yy;)
_________; //拷贝构造函数
private:
int X, Y;
};
myClass::____________ //拷贝构造函数的实现
{
X=________;
__________;
}

3、根据不同的输出结果,在函数Tone中填入正确的语句。
#include <iostream.h>
class Instrument
{
public:
virtual void Print() const
{ cout<<"Instrument::Print"<<endl;}
};
class Piano: public Instrument
{
public:
void Print()const { cout<<"Pinno::Print"<<endl;}
};
class Guitar: public Instrum

1
friend
Myclass
Myclass
2
Myclass(Myclass& tar)
Myclass(Myclass& tar)
tar.X
Y=tar.Y
3
(1)Instrument tong
tong.Print();
(2)Instrument& tong
tong.Print();
4
4/15/2005
5/15/2005
8/10/2005
2/6/2007
5
Member or D1
Member or B1
Member or B2
6
Max("hello","Gold") is hello

1.
inline int GetNum (const Myclass &my);
int Myclass::GetNum(const Myclass &my)
{
return my,x;
}
或者
friend int GetNum (Myclass &my);
int GetNum(Myclass &my)
{
return my,x;
}
2.
Myclass(const Myclass &other);//拷贝构造函数
Myclass::Myclass(const Myclass &other)
{
X=other.X;
Y=other.Y;
}
3.
(1)Instrument tong
tong.Print();
(2)Instrument& tong
tong.Print();
写出下列程序的运行结果
4/15/2005
5/15/2005
8/10/2005
2/6/2007

Memb