I'm reading to brush up on C++ knowledge that is almost 2 decades old in order to understand online info on the factory pattern. The final usage context will likely be in a different 3rd generation language (3GL), but because of my past experience, I think it's easier to follow C++ than (say) Java, even though the latter may be less intricate in syntax. A bigger reason, however, is that the only code example I can find of the problem being addressed, i.e., in the absence of the factory pattern, is in C++. Most posts talk about the reasons for the pattern in high level narrative, then provide code to show the mechanics of the pattern instead of the problem in the absence of the pattern.
The code I'm studying is located here. I'm having trouble making sense of the fact that delete[]
is used to destroy objects that are created using new
. According to various readings, delete
is used with new
, and delete[]
is used with new[]
. After so long away from C++, however, I could quite easily be overlooking something obvious. Is the cited code OK, or am I right?
My readings on new
and delete
are: