Java interfaces and C ++ header / implementation files are different concepts.
C ++ has a text compilation model. So, in order to use something - for example, a function - in code, the compiler must first analyze the definition of that function. Putting things in header files that you want to use from many source files eliminates the need to rewrite the definition of a function, because you can include the same header file in many source files that use things in this header.
Functions in C ++ can be declared by simply writing the name and arguments of the function:
void PrintMessage(std::string text);
And they can be defined by writing the body of the method too:
void PrintMessage(std::string text) { cout << text; }
You can define a function only once in a compilation block (this is all the text that the compiler sees after #includes has been replaced with the text of the file that they include). But you can declare a function many times as long as the declarations are the same. You must define each function that is called once. This is why you have a .cpp file for each .h..cpp file that defines all the functions declared in the .h file. The .h file is included in all .cpp files that use these functions, and is included once in the .cpp file that defines the functions.
Java works where function definitions are for you when compiling a project, when it views all the files in the project. C ++ only compiles one .cpp file at a time and looks only at #include header files.
The Java interface is equivalent to the C ++ base class. This is essentially a declaration of a set of methods, including the types of arguments they accept and the type of return values. The Java interface or the C ++ base class can be inherited by the Java class or the C ++ class, which actually defines (implements) these methods.
In C ++, when you create a class, you usually (with exceptions) put method declarations in the header file, and you put the definitions in the .cpp file. But in Java you only need to write method definitions, these definitions make the equivalent of a C ++ definition and declaration in one. You can put all java method definitions in one file.