Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The fundamental reason why the .cpp file has so many functions preceded with <code>VideoEncoder::</code> is that the .cpp file contains the <em>implementation</em> of what the .h file declares as the <em>interface</em>. It is common practice in c++ to declare the class's functionality in the header file and then implement it in a separate .cpp file.</p> <p>One benefit is that whenever you decide to change the implementation details of the class (leaving the interface untouched), you will have to only re-compile the .cpp file. Everything else needs not be recompiled. Developers also try to utilize this technique to the max trying to declare as little as possible in the .h file. Read more about the <a href="http://en.wikipedia.org/wiki/Opaque_pointer" rel="nofollow noreferrer">pImpl pattern</a> (after reading a good c++ intro). The basic idea is that the less info is in the .h file, the less time will be required to re-compile the files that include this header file. So you only put into the .h file functions that are absolutely essential for the class's clients to understand what the class is all about.</p> <p>As for why the functions declared in the .h file work perfectly without ever referencing the .cpp file -- it's all about the way c++ programs are compiled. People are right saying that you need to pick a book on c++ and study it carefully. Anyway, the concept of a c++ program is that the program consists of compilation units -- individual .cpp files that can be compiled independently. You only need to <code>#include</code> the functionality that your individual .cpp file is using. The compiler is satisfied with that on this stage. However, there is another stage -- <em>linkage</em>. On this stage the linker checks whether there are actual implementations available. It does so by searching the .obj files (generated by the compiler) and evaluating whether there is an entry corresponding to a certain class function. If the entry is not available, you will see a linker error (note that the compiler will not report any errors because the function was declared somewhere, but not implemented).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload