您当前的位置: 首页 > 

柳鲲鹏

暂无认证

  • 1浏览

    0关注

    4642博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

重载下标操作符,检查内存越界

柳鲲鹏 发布时间:2019-03-12 16:03:18 ,浏览量:1

  前一篇文章,吾提出重载下标操作符[],实现内存越界检查.于是网上搜索了一下,找到一个范例,测试通过:

#include 
#include 
#include 

using namespace std;

class SafeArray
{
public:
    SafeArray(const int size) 
    {
       nSize = size;
       pData = (int*)malloc(sizeof(int)*nSize);
       //memset(pData, 0, sizeof(int)*nSize);
       for (int i=0; i nSize )
        {
            cout             
关注
打赏
1665724893
查看更多评论
0.0550s