0

In c++, Is there any reason to initialize using arguments over member variables ( Or vice versa )?

A reason is different from an opinion. And I qualified that I was interested in whether there was a performance advantage on doing one over the other, which is objectively measurable, and hence, "Not an opinion".

So I'd like this question re-opened, and an explanation from the moderation responsible for this.

4

Well, the literal reason for closage is questionable. But IMHO the post looks a lot like one of those micro-optimization questions where the only viable answer is "it will most probably depend on the specific compiler, maybe the compiler version and the optimization options used, as well as from the difference between your real code and the code posted here". This does not make it a particular interesting question of long-lasting value for others. The voters may have just chosen the "too opinionated" close reason in lack of a better predefined one (but I can only guess, and I know that those specific community members rarely feel obliged to explain their votes, so don't expect them to show up here).

If you really want to know if there is a performance difference between those two similar looking code snippets, your best shot would probably be to use the Godbolt compiler explorer and try out what assembly code different compilers and versions of them will produce.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .