Gary Pendergast wrote:
> Hi folks,
>
> Here's something I've been running into occasionally:
>
> class Foo
> {
> int whee;
> public:
> Foo() : whee(10) {};
> }
>
> I just spent far too long debugging a problem that should have taken 2
> minutes, because I didn't realise 'whee' was being set in the class
> declaration.
>
> Personally, I'm a fan of "no program logic in the .h files at all", but
> I'm not sure if this topic has been discussed at all.
Well... a couple of things here.
It's definitely preferred to use initializers like above. Whether that
code is in .h or .cc is sort of up to judgment.
The nice thing about putting some (especially smaller) pieces of code in
the headers is that it can be inlined elsewhere. So while I agree with
you in theory from a code cleanliness perspective, from a practical
perspective we wind up with a pretty decent amount of code in the headers.
Monty
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp