C++题目 定义一个datatype类,能处理包含字符型、整形、浮点型3种类型的数据,写出其构造函数...

来源:百度知道 编辑:UC知道 时间:2024/05/27 08:55:22
*******虽很简单,但还是请朋友解答一下,本人初学.谢谢!*********

有两种写法:

写法1: class datatype
{
public:
datatype(); //构造函数声明
protected:
}
.....
datatype::datatype()
{
char a;
int b;
float c;
}
*----------------------------------------------------
写法2:class datatype
{
public:
datatype()
{
char a;
int b;
float c;
}

protected:
}
不知道你还有什么具体要求,如果有的话,加我qq:59366845聊会比较方便点.

typedef struct {
char mType[100];
int nInt;
float nFloat;
} INFO_Buf,*pINFO_Buf;

class DataType
{
public:
char c;
int i;
float f;
DataType(char c)
{
this.c = c;
}
DataType(int i)
{
this.i = i;
}