I wrote this code to for HW. I'm supposed to do a hash function and display information about the searched ship, first I have to get the data from a file and then manage it. Although the code has no build errors once I start debugging it suddenly crashes at line #28, which is in the constructor, when the 1st and only object in main is created. I get a message that says "Cannot open file: ../../../../../src/gcc-5.1.0/libgcc/unwind-sjlj.c" I can't start debugging so most likely functions do not do what they are intended to do, but the problem here is the file that cant be open for some reason. I have run this code in other machines with the exact same issue. I have never seen this "error" before and google either apparently :c. HELP.
string type = {};
string name = {};
string year = {};
string cap = {};
but this is not necessary.
This is also not correct, but harmless. If it didn't work it would just have given you a compilation error.
int serialNum = NULL;
Remember that NULL is for pointers, and pointer-like objects. Also note that in modern C++ we often use nullptr instead of NULL because it has a few advantages.
Also note that in modern C++ we often use nullptr instead of NULL
Even in older C++ we usually used 0. I guess the old (void*)0 definition would cause problems! And if NULL is always defined as plain old 0 (as it should be in C++), then it really has no purpose.
But I guess nullptr is better.
NULL is allowed to be defined as nullptr since C++11
That's interesting. This is how it looks in gcc:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* A null pointer constant. */
#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL /* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else /* G++ */
#ifndef __cplusplus
#define NULL ((void *)0)
#else /* C++ */
#define NULL 0
#endif /* C++ */
#endif /* G++ */
#endif /* NULL not defined and <stddef.h> or need NULL. */
#undef __need_NULL