Error: illegal pointer to class object <histogram> 0x0 1401

I’ve got this error message and I wrote the part of my code below,

TH2D* fg2d_temp[8][4] = {0};

fg2d_temp[0][0] = (TH2D*)fin->Get(“fg2d_0_0”);

fg2d[0][0] = (TH2D*)fg2d_temp[0][0]->Clone();

I’ve checked that fg2d_temp is well written in infile ‘fin’.
It may be a silly question, but I have no idea what this message means and why this error message showed.
Could you give any suggestion?

Best
tachy


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,
that means that you are using a null pointer (0x0).
You should check that the pointers coming from fg2d_temp that you use are not null (the simplest way is to print their values before you use them, you should see that one of the pointers you use is 0 or nullptr).

Cheers,
Enrico

1 Like

Thanks, I printed my pointer and got 0.
I got null pointer because I made a typo when I get histogram from the file… I found it after following your suggestion. Thanks a lot!