3 ms·
I think the important thing isn't what happens internally, but what it looks like from the outside. Fundamentally, invoking a (non-virtual) superclass's method
by parenthephobia 11y ago
I think the important thing isn't what happens internally, but what it looks like from the outside.
Fundamentally, invoking a (non-virtual) superclass's method in C++ doesn't do much more than forward that method to an inner struct.
struct Reader {
int fd;
}
struct Writer {
int fd;
void Write (int) {
// *this* points to the Writer, not the ReadWriter
}
}
int writeForMe (Writer *w) {
// *w* points to the Writer, not the ReadWriter
}
struct ReadWriter: Reader, Writer {
}
The only real difference, aside from the syntax, is that in C++ one can dynamically convert a pointer to a Writer that is part of a ReadWriter into a pointer to that ReadWriter, something Go doesn't support.