We had better put the member function in/out of the class body?

I found that: as long as we put the member function's definition in the class body, there won't be any "multi-definition" problem when the header file is included several times.
Then my question is:
why would I love to put a member function definition in a separated cpp file?
Last edited on
1: It looks better.

2: It's considerably more modular.

3: I've had some trouble placing member function definitions in the class body in a header file when there were multiple cpp files that required the definitions. Linker errors occurred.

-Albatross
You mean I just didn't type in any complicated enough member function yet? Later on, I will find the beauty of using a separated cpp file?
Oh indeed, and it's a must have (for me anyway) if one has a function or member function whose definition is longer than three pages.

Gee, I once did something really stupid with defining a long function outside of a separate C++ file... good times...

-Albatross

P.S. - The function's definition was 1257 lines long. I even remember the exact number.
What happened then? Spend long time to finish compiling?
Nah, I have an excellent compiler, known as g++.

However, the code was VERY painful to read through.

-Albatross
oh, I see, Thank you so much!
Topic archived. No new replies allowed.