So I understand that template functions need to be declared and defined in the same file.
My question is, in the following code, for example, do I need to bother with the function prototypes or should I just put the functions and definitions in the class.
My question is, in the following code, for example, do I need to bother with the function prototypes or should I just put the functions and definitions in the class.
It's your preference. Either one will work just fine.
The only difference is a style/code clarity issue. Some people would think keeping the functions outside the class is more organized because you can quickly see all members just by examining the class.
You could also declare your templates in a header and put the implementation in another file, and include the implementation and the end of the header.
I like the style you chose to use! It's ok for very small classes to define their few methods inline, but then it's better to move them out of the body.
I do sometimes make an exception for the constructor and destructor. Unless the initializer list gets esp long.
Note that according to best practice, the order of member variables in the initializer list should be identical to order in which the variable are declared.
In the MFC / ATL world the inline functions are put in .inl files. But I wouldn't expect to see these in app development (cf. library development), as it's better to limit files to one class (expect for sets of tiny utility class, etc)
Andy
P.S. I have another couple of observations, but won't force them on you!
on a side note, you really shouldn't prefix variable names with an underscore.
Identifiers starting with an underscore is a convention reserved for compiler keywords, so you run the risk of colliding with a compiler keyword if you do this.
What drama are you talking about? It was a carefully planned
(from both sides) operation to teach other people two things:
(1) If you don't know the meaning of a word,
google it instead of making assumptions.
(2) If you don't know whether someone is trolling or not, ask yourself "what's more probable based on his past behaviour?" before you act.
Even Grey Wolf's goodbye letter was a fake, as he's still here.
I really can't believe the fact that so many people fell for that
('that' meaning the whole story, not just Grey Wolf's letter).
If I am not him and he not me; what does it matter?
If I say I not him, would you believe me? Probably not, so what does it matter?
So m4ster r0shi, what do you want?
Do you want me to say what a clever boy you are? Not going to happen.
Do you want me to leave to forum? I tell you what; I’ll put the power in your hands. Report this post and twicker can gladly close this account (as long as the report comes from you).
I have no interest in playing games with you, I have no interest in further interacting with you, and I have no interest in justifying myself to you. Let’s face it, I have no interest in you.