3 ms·
They are a useful mechanism for linking different parts of a program without having to couple objects together. OOP can lead to a lot of inflexibility, but hist
by hellofunk 11y ago
They are a useful mechanism for linking different parts of a program without having to couple objects together. OOP can lead to a lot of inflexibility, but historically has been the most obvious mechanism in C++ for one object to learn about what another object is doing: pass a pointer to itself, etc. But this often requires inheritance, polymorphism, virtual interfaces, a number of idioms that can complicate this basic requirement. Signals and slots allow the objects to not know anything about each other, not store pointers to each other, be more or less isolated, except for this one little connection between them that is otherwise anonymous to both.