A Brief Introduction to C++ Classes

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ • 3

  • @maxg4958
    @maxg4958 5 місяців тому

    Thank you. Now add a header file :) Nice effort.

    • @rwissbaum9849
      @rwissbaum9849  5 місяців тому +1

      This video has been online for over a year, and yours is - as you noticed - the *first* comment I've received. Thanks! Obviously, the next step is to create a library, but since this video has been viewed less than 200 times in a year, I doubt that there would be much interest in a how-to video. However, if you want to create a library, here's how:
      First, put all the definitions (class definition and constant definitions) into the header file and all of the code into a .cpp file.
      Second, create a keywords.txt file (this tells the IDE how to format the on-screen text) and a library.properties file (which is just some text describing the library.)
      Third, if you *do* *not* want the library to be read-only, create a file (it may be empty) named .development.
      Next, create a folder under the libraries folder in your default sketch directory and give the folder the same name as your library. Create a sub-folder called src and place the header file and all supporting .cpp files in the src sub-folder. Then place keywords.txt, library.properties, and optionally .development in your library folder.
      Once this is done, you can include the library in your sketch in either of two ways: (1) add the compiler directive #include to your source file, or (2) in the IDE menu, select Sketch/Include Library and then select your library from the menu list.
      The header file should include a few compiler directives to prevent recursive inclusion - otherwise, your code could blow up. Study some of the supplied library header files for examples.
      Thanks for watching!

    • @maxg4958
      @maxg4958 5 місяців тому

      @@rwissbaum9849 I appreciate the detailed response, though I know how to do it :) As we know, having a class as header and implementation files, makes the class more 'independent' from where it is used. As for number of views, it is a self-perpetuating system; no views = low ranking; more views higher ranking.