I have found some threads that explain why C++ separates .cpp and .h files (e.g. here). I'd be interested to know if it causes any problem if I don't separate them. I don't want to share the object files, so what's the benefit of the separation on a small project? If it just slows down the compilation time, it's not a big deal in my opinion. I want to re-implement a Java program in C++, so to me it seems much easier to keep a class in one file only. Example:
// Hello.cpp
#ifndef HELLO_20091218
#define HELLO_20091218
#include <iostream>
#include "Utils.cpp"
class Hello
{
public:
void start()
{
std::cout << Utils::nrand(100) << "\n";
// Utils and all other classes are written in a similar way
}
};
#endif
There is a thing that troubles me. "Defining a member function inside the class asks the implementation to expand calls to it inline." So if I do like this, everything is marked inline implicitly. Will it cause a larger executable or any other disadvantages?