Tag Info

New answers tagged

1

Null is evil. However, the lack of a null can be a greater evil. The problem is that in the real world you often have a situation where you do not have data. Your example of the version without nulls can still blow up--either you made a logic mistake and forgot to check for Goodman or perhaps Goodman got married between when you checked and when you ...


-3

NULL is a problem because it conceptually represents data that may or may not exist. Data that may not exist is assumed not to exist (because assuming the opposite crashes your program so you always have to assume the value could be NULL). Data that doesn't exist is not worth reasoning about, and is not very useful. If your program is mostly not useful, you ...


2

Different linked libraries may use different heaps. This makes dynamic allocation and memory management tricky. The most common way is to make Person an opaque struct (declared but not defined in the public header) and the programmer using it must use the functions in the library to get access to the attributes. This means that allocating and freeing will ...


2

Your question is a matter of opinion, however, it looks like Person is generally supposed to be allocated in the heap (read about C dynamic memory allocation). Then you should define and document how Person-s are allocated and who is in charge of free-ing them and when. I would suggest to have a function to create Person-s like Person* ...



Top 50 recent answers are included