#ifndef __ACCOUNT_ARRAY_H__
#define __ACCOUNT_ARRAY_H__
#include "Account.h"
typedef Account * ACCOUNT_PTR;
class BoundCheckPointPtrArray
{
private:
ACCOUNT_PTR * accArr;
int arrlen;
BoundCheckPointPtrArray(const BoundCheckPointPtrArray& arr) { }
BoundCheckPointPtrArray& operator=(const BoundCheckPointPtrArray& arr) { }
public:
BoundCheckPointPtrArray(int len=100);// len을기본으로 100개 먹임
ACCOUNT_PTR& operator[](int idx);
ACCOUNT_PTR operator[](int idx) const ;
int GetArrLen() const;
~BoundCheckPointPtrArray();
};
#endif // !__ACCOUNT_ARRAY_H__
BoundCheckPointPtrArray::BoundCheckPointPtrArray(int len):arrlen(len) //100개 만들고
{
accArr = new ACCOUNT_PTR[len];
}
ACCOUNT_PTR& BoundCheckPointPtrArray::operator[](int idx) // 100개 초과되면 밑에 if문 출력
{
if (idx<0 || idx >=arrlen)
{
cout << "Array index out of bound exception" << endl;
exit(1);
}
return accArr[idx];
}
ACCOUNT_PTR BoundCheckPointPtrArray:: operator[](int idx) const
{
if (idx<0 || idx >= arrlen)
{
cout << "Array index out of bound exception" << endl;
exit(1);
}
return accArr[idx];
}
int BoundCheckPointPtrArray::GetArrLen() const
{
return arrlen;
}
BoundCheckPointPtrArray::~BoundCheckPointPtrArray()
{
delete[]accArr;
}
저기 기본으로 100개를 만들려고 하는데 디버깅중에 값이 둘다 0으로 뜸 왜이런거냐
잘 봤습니다
복사되고있는거 아님?
일단 저거 일반 배열 말고 std::array 쓰고 new delete 쓰지 말고 unique_ptr 쓰셈 가이드라인 바뀌어서 더 이항 저렇게 할 필요가 없음 그리고 클래스 정의 말고 생성되는 부분 보여줘야 될 것 같음 - return 0;
생성되는 부분?
메인 코드 부분 - return 0;
일단 올려봄