我正在尝试Uint8
通过嵌套类为类型数组分配内存。当我这样做时,我认为它会运行到堆错误并提示显示调试断言错误的窗口。表达式:_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)。我的代码如下:
#include <iostream>
#include "dcmtk/dcmdata/dctk.h"
using namespace std;
class test
{
public:
int a;
Uint8 * b;
test()
{}
test(int c)
{
a=c;
b = new Uint8[a];
}
~test()
{
delete [] b;
}
};
class subTest
{
public:
test h;
subTest()
{}
subTest(test g)
{
h=g;
}
~subTest()
{
}
};
int main()
{
subTest f(test(5));
for(int i=0; i<5; i++)
{
f.h.b[i] = Uint8((i*2)+1);
cout<< int(f.h.b[i])<<endl;
}
return 0;
}
你能找出我做错了什么吗?
谢谢。