So I have created a few classes which are really useful to me , from what I gather "best practice" is to prototype your functions your class will have , obviously declare your variables inside the class as private/public etc.
My question is this (and I understand I am wrong, but I am not sure why its wrong). If I had some basic functions just using the variables inside the class why can I not just write the function/functions inside my class thats inside the header, rather than prototyping them in the header and adding another cpp to contain my functions?
As I said I know its "wrong" to do that , but I would like to know the exact reasoning behind it.
1) Theoretical explanation: this is done to separate interface and do not expose implementation to end users. Also that means less code will clutter your class declaration, allowing users to see interface more clearly.
2) Practical explanation: If you change function in cpp file, you only need to recompile this file and relink project. If you change header, you need to recompile all files using this header either direcly or indirectly, which often means entire project.