永发信息网

c++程序问题

答案:2  悬赏:20  手机版
解决时间 2021-03-21 07:42
  • 提问者网友:我们很暧昧
  • 2021-03-20 08:13
#ifndef ARRAY_CLASS
#define ARRAY_CALSS
#include
#include
#ifndef NULL
const int NULL=0;
#endif
enum ErrorType
{
invalidArraySize,memoryAllocationError,
inderOutOfRange
};
char *errorMsg[]={"invalid array size","Memory allocation error",
"invalid index:"};
template
class Array
{
T *alist;
Int slze;
void Error(ErrorType error,int badindex=0)const;
public:
Array(int sz=50);
Array(const Array&A);
~Array(void);
Array&operator=(const Array&rhs);
T&operator T*(void)const;
int ListSize(void)const;
void Resize(int sz);

}
template
void Array::Error(ErrorType error,int badIndex)const
{

cout<if(error==indexOutOfRange)
cout<cout<exit(1);
}
template
Array::Array(int sz)
{
if(sz<=0)
Error(invalidArraySize);
size=sz;
alist=new T[size];
if(alist==NULL)
Error(memoryAllocationError);

}
这段怎么理解了那为告诉我下了谢谢了
Array(int sz=50);
Array(const Array&A);
~Array(void);
Array&operator=(const Array&rhs);
T&operator T*(void)const;
int ListSize(void)const;
void Resize(int sz);
最佳答案
  • 五星知识达人网友:由着我着迷
  • 2021-03-20 09:05
//这段叫函数声明.
Array(int sz=50); //构造函数
Array(const Array&A); //复制构造函数
~Array(void); //析构函数
Array&operator=(const Array&rhs); //重载赋值操作符
T&operator T*(void)const;//重载指针转换操作符
int ListSize(void)const; //
void Resize(int sz);//
全部回答
  • 1楼网友:街头电车
  • 2021-03-20 10:03
1这两个函数有一定的区别,首先他们不在同一个头文件中,scanf在stdio.h中;gets在iostream.h中;;还有gets将读入的数据按字符处理,而scanf将读入的数据按指定的类型处理。 2    a=123456.789e5;  //a被赋予什么值? e5是什么意思 一个数使用123456.789e5表示,用了科学计数法,后面的e5表示乘10的5次幂。还有比如22.34e-5表示22.34乘10的-5次幂。 3 //为什么a和b都是输出12345678848.000000 对于浮点型数据来说,最多可以精确到第7位,后面的各位都已经不能精确表示。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯