Why do we need to include the .h while everything works when including only the .cpp file?
        Posted  
        
            by 
                reaffer
            
        on Programmers
        
        See other posts from Programmers
        
            or by reaffer
        
        
        
        Published on 2014-08-23T16:47:01Z
        Indexed on 
            2014/08/24
            4:31 UTC
        
        
        Read the original article
        Hit count: 281
        
Why do we need to include both the .h and .cpp files , while we can make it works with making just a .cpp file and then including it .
For example, Creating a file.h containing declarations, then creating a file.cpp containing definitions and including both on the main.cpp.
Or, creating a file.cpp containing declaration/definitions ( no prototypes )
Including  it on the main.cpp.
Both worked for me , but still can't the difference since i do not have a background on the compiling and linking process .
© Programmers or respective owner