Show newer

@vaporeon_ you can either inherit something publicly, privately, or protectedly

furthermore, there is virtual or nonvirtual inheritance

so there is private virtual, private, protected virtual, protected, public virtual, and public inheritance

@vaporeon_ did you know that in C++, there are six different ways to inherit a class

@vaporeon_ since that emojo is holding its forehead I am imagining you got a second ice cream and are currently experiencing brain freeze

@monorail @vaporeon_ @aescling it wasn't a reference to anything, you were just there and I felt like saying something nice

@vaporeon_ @aescling I don't like that they don't add anything new, and simply give you a second way to do something the language could already do

I think it is very Bad for languages to do that sort of thing

@vaporeon_ @aescling using operators in C++ is sugar for a function call, where whatever is given to the operands is provided to the function that represents the operation

of course Bjarne could have decided that pointers of these operands would be provided to the function representing the operations, but that would be too simple. so instead, he added references, and also ruined the language forever

@vaporeon_ @aescling C++ actually implicitly converts objects to references if the function is declared to take reference arguments

#include <iostream>

class T {};

void use_T(T& t) { std::cout << "I used a T!\n"; }

int main() {
T t;
use_T(t);
}

@vaporeon_ @aescling yes. in C everything is passed by value between functions, so technically the pointer is copied from main to changeObj

but pointers are just numbers so the literal address in memory that pointer refers to doesn't change

@vaporeon_ @aescling there's no optimization in using a reference over a pointer, it's a style thing

@vaporeon_ @aescling they do function as aliases to an existing object but they still pass by value when given to functions, so they can be used in any situation where a pointer can be used because C++ likes giving you multiple ways to solve every problem

@vaporeon_ @aescling it will create an object with a single property named _this that has the value of whatever this was where the arrow function was declared

and then it will delete that property from the object

Show older
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.