/* Copyright (c) 2016* All rights reserved 烟台大学计算机与控制工程学院
* 文件名称:3.cpp
* 作者:刘丽
* 完成日期:2016年 5 月 24日
* 版本号: v1.0
【项目-数组类运算的实现】
设计数组类Array,为了实现测试函数中要求的功能,请补足相关的函数(构造、析构函数)和运算符重载的函数。
实现策略提示:可以将测试函数中的语句加上注释,取消一句的注释,增加相应的函数,以渐增地实现所有的功能,避免全盘考虑带来的困难。
*/
#include<iostream>
#include <cassert>
using namespace std;
class Array
{
private:
int* list; //用于存放动态分配的数组内存首地址
int size; //数组大小(元素个数)
public:
//成员函数声明
Array(int s = 50);
Array (int a[],int);
Array(const Array &a);
Array operator+(const Array &b);
void show();
void resize(int );
int &operator[](int);
const int &Array::operator[] (int) const;
Array &operator = (const Array &a2);
};
Array::Array(int s)
{
size=s;
list=new int [size];
}
Array &Array::operator = (const Array&a
【运算符重载-数组类运算的实现】
最新推荐文章于 2022-08-12 00:54:20 发布