Note 1: To make what I'm asking most clear: Does the new title stay true to the OP's problem, the way she/he saw it?
Note 2: I do agree, as I have already said in the comments, that there can be multiple readings here of the OP's intentions. Hence, I do see how this question could be too broad. I have in fact voted myself to close it as such.
As many posters asking a question don't know what their problem is (part of why they're asking), aren't duplicates supposed to be marked for posts asking the same question from the OP's perspective, in the hope that other people having the same question in their mind could find it easily and connect the dots, instead of re-writing the title to mean something else and linking it with an older post agreeing with the now edited title?
I already learned there's no official statement regarding the exact definition of a duplicate, and I got the feeling this is an on-going debate here, but couldn't find an answer on meta that felt like it applies exactly to this case: This question had its title completely re-written, and so was the case with the older question being marked as one that already has an answer. To me, it seemed quite clear the OP in the newer question had failed to realize the case in point of the older question, but this had lead her/him through her/his own thought-process, ending up with the OP surmising about in-memory structure of the container at hand. This obviously requires the additional, earlier part of building an answer for -- a part that doesn't show up in, as it has nothing to do with, the answer to the older question.
Original title of the now closed post was: 'How is memory allocated for vector in C++?'. The entire text of the post: For every primitive data type memory locations are contiguous, except for char. It prints some garbage value on the screen. I tried adding v.reserve(4), but the output was the same. A large enough portion of this text now seems a bit baffling, coupled with the new title being: 'Printing addresses of vector's elements shows garbage', as it has nothing to do with memory allocations or contingency, etc. But this new title definitely agrees with the now-edited title of the older post: 'Why does streaming a char pointer to cout not print an address?'
To me it seemed we have an older question asking about how to print address of a char
and the newer question explicitly asking what's up with the "memory allocations" of a std::vector
. Other people might be sharing a similar thought process with the OP of the newer question. Hence, after the title re-writing and the dupe closure (for what may seem to them as a completely different question) they could more easily be prevented from finding the right answer -- which potentially would lead them to ask the same question as this one being now closed as a dupe.
Is this the desired cause-and-effect of closing as a duplicate?
Saying that the answer to the newer question is solving the exact same problem the older question had is doubtful if you take it that a part of the newer OP's problem was not knowing how std::vector
is structured in memory, or at least he wasn't sure about it and so that's why he literally asked about it. I'm not at all sure this constitutes in mere different wording of the same question.
Further, the fact that the unexpected output is the reason these questions exist doesn't map one to one with the problem each OP had. Or is it really the case both OPs are just asking why they get garbage output? Looking at the text quoted above, it seems to me that the mention of garbage is only understood in composition with the other sentences in the question being about in-memory structure.
From the comments: At no point it is claimed that dupes need to be an exact match. Here, for example, I'm particularly bothered by the fact that the answer on the newer post would seem pretty perplexing, at least the opening part, if read as an answer to the older post. Far from asking for an an exact match, but at least should be read coherent. I will be in the wrong of course, in case most people think the new answer could go smoothly enough when coupled with the old question. Let me know in an answer or comment if you feel like it, but please try explain how this is or isn't the case.
Am I missing anything here? please correct me.