Class story
I. Class basic
class, public:, private:: public members (create, start, stop)
can be called from outside the class. private members (_pipeline, _loop, _instance) are internal.
Constructor and destructor
1. Why is this constructor empty?
Detection() {}
https://www.geeksforgeeks.org/cpp/constructors-c/ https://www.geeksforgeeks.org/cpp/copy-constructor-in-cpp/
2. When does a constructor need content?
The rule: if every member initializes itself correctly, leave the constructor empty

3. Why the destructor does have content
~Detection() { stop(); }
unique_ptr would free the pipeline automatically, but GStreamer needs these steps in this order:
- quit the main loop
- set the pipeline state to NULL
- then free it
Member destructors only free memory; they don’t know about this order. That’s why the destructor needs code.
The rule: write a destructor when cleanup is more than freeing memory, or must happen in a specific order. If every member cleans up after itself, you don’t need a destructor at all.
After the destructor body runs, members are destroyed automatically in reverse order of declaration: _loop first, then _pipeline.
All rights reserved