How can I catch Null Referencee Pointer exception | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I catch Null Referencee Pointer exception

I want m'y pointer to be read only if he has a value

26th Dec 2016, 6:23 AM
Mattis BETOURNE Clara HORVENO
Mattis BETOURNE Clara HORVENO - avatar
1 Answer
+ 1
You should set all of your pointers to nullptr when being deleted or allocated, so then you can just ask: if (pointer==nullptr) throw -1;
26th Dec 2016, 8:14 AM
Faris Hasković
Faris Hasković - avatar