you're going to be written out of the will and inherit diddly squat if you keep posting AI slop young man
>>105945881I prefer for . to automatically dereference pointers to struct
>composition over inheritance
Just like the crab ordered.
>typedef struct
cniles really live like this......
God I love OOP!
class Program
{
struct Position : this(int x = 0, int y = 0);
struct Car : this(Position position);
struct Truck : this(
int id,
Position position = default);
static void MoveRight<T>(this ref T vehicle)
where T : var =>
vehicle.position.x += 1;
static void PrintPosition<T>(this T vehicle)
where T : var =>
Console.WriteLine("{}, {}", vehicle.position.x, vehicle.position.y);
static void PrintID(this Truck truck) =>
Console.WriteLine("ID: {}", truck.id);
public static int Main()
{
Car car1 = default;
car1.position.x = 0;
car1.position.y = 0;
car1.PrintPosition();
car1.MoveRight();
car1.PrintPosition();
Truck truck = .(69);
truck.PrintID();
truck.position = .(x: 10, y: 10);
truck.PrintPosition();
truck.MoveRight();
truck.PrintPosition();
return 0;
}
}
>>105946332>>105946518The worst part is that these typedef'ing niggers are the majority of C programmers.
>>105946528the C standard even says typedeffing is bad especiallt when you do shit like yourmom_t
>>105945618 (OP)You can pass car_0 as car.position, just cast it as position.
>>105945618 (OP)wow this is
>>105946554i find it hilarious how much people (rightfully) sneed over hungarian but cniggers love spamming _t bullshit everywhere for no reason
>>105946720Nobody does this except POOSIX trannies.
>>105946815main(){} would be enough in older C versions
>>105946734Just outed yourself as a nocoder.
https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_02_02
>>105946823But invalid in C23 and no more efficient, hence irrelevant.
>>105946820Doesn't get any more efficient than that. It does the equivalent useful work as that C++ OOPslop.
>>105946916>Didn't contest being a nocoderI accept your concession.
>>105946944nta but there are more runtimes than just POSIX and NT, and if youre writing C code for a living, chances are youre not working on any of those systems
Inheritance is gay and no one uses it in a serious production setting
>>105946987Jews use inheritance all the time, that's how they succeed while goytards like you still dig through shit and seethe constantly about not being able to find a job.