What is the point of defining methods outside of a class in C++?

c++

Solution

A big reason is to reduce the number of files that need to be recompiled when implementation changes. Say the interface definition of your question class is stable and won't change much, but you are still working on the implementation of its methods.

If u put all the implementation in the header than all the files that include your header will have to be compiled. The classic examples are template based code which increase the compilation time as their method bodies always have to be visible in header files.

Problem

As a Java guy trying to learn C++ I'm a little confused as to why you would want to do something like this ``` class question{ private: string ques; public: question(string ques) } question::question(string ques){ this->ques = ques; }; ``` versus just ``` class question{ private: string ques; public: question(string ques){ this->ques = ques; } }; ``` Does it have something to with "inline"? I don't quite know what that means either.

Original source