I'm trying to allocate memory for Uint8
type array through a nested class. When I'm doing so I think it runs to heap error and prompts the window that says Debug Assertion Error. Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse). My code is the following:
#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;
}
Could you find what mistake I'm doing?
Thanks.