Ask Everyone: Where’s your Constructor? April 11, 2008
Posted by Brent in computers.Tags: code, programming, style
trackback
Where do you prefer to put your object’s constructor in relation to the file’s line numbers?
Near the top? Before or after the member object declarations?
——————
I prefer to keep them near the top, preferably after the private member declarations. It’s not a hard or fast rule for me, but I dislike it when the constructor(s) is/off mingling with other methods in the middle of the class.
Always at the top. It really doesn’t make much sense to put it elsewhere.
Of course, if this is not production code (still in development), then it can go anywhere it pleases.