Is it necessary to seperate the headers from the source?
For example I don't know why but I love to do:
//Foo.H
class Foo
{
Foo(){}
~Foo(){}
void Func()
{
//.........
//.........
}
void Func2()
{
//........
//........
}
};
Instead of doing:
//Foo.H
class Foo
{
Foo();
~Foo();
void Func();
void Func2();
};
//Foo.cpp
Foo::Foo()
{
//.....
}
Foo::~Foo()
{
//......
}
Foo::void Func()
{
//.....
}
Foo::void Func2()
{
//....
}
The second example which Hate to do seems like so much more work. Not only that but I'd have to constantly switch back and forth between headers and sources to see whats declared where or what contains what. But now I'm looking up all my habbits to see if they cause performance degradation and I've read the first one does whereas the second doesn't :S
I'm also reading that if i put my definitions inside the class, it's automatically inlined and that if I put the inline keyword in there then it's even worse :S Should I just leave them in there as inline and if not then why? Is there a way to define them inside the class and NOT be inlined?
Is this true? Am I actually doing something bad? I'm being told to never put the definitions in a header.. Only declarations.. Apparently it slows down compile time and slows down my program which is what I read at stack overflow from someone asking a similar question. I use header guards by the way.
I just really don't like having that many unneccesary files when I can just include my header with everything in there already..
So is it bad? Also why should a coder use the scope operator like that instead of putting it all inside the class? Is there an advantage such as performance/compile time or is it just style? C# doesn't seem to care whether or not everything is in one file..