r/programmingmemes • • 6d ago

C++ VS python

Post image
754 Upvotes

37 comments sorted by

View all comments

Show parent comment

8

u/SpaceCadet87 6d ago
#include <cake>

int main() {
    Cake myCake("Chocolate", 3, true);
    myCake.serve();
    return 0;
}

1

u/Total-Box-5169 5d ago
#include <cake>

int main() {
    Cake{"Chocolate", 3, true}.serve();
}

2

u/SpaceCadet87 5d ago

Oh, I didn't realise we were doing code golf.

M{Cake{"Chocolate",3,1}.serve();}

g++ -D'M=int main()' -include cake x.cpp

1

u/DatsLotus 4d ago

Damn, you've bested me. I could only follow up until the previous one.

2

u/SpaceCadet87 4d ago

Ah, basically I told the compiler to do a find and replace so that instead of int main() you just type M and you can do an include at the command line so we throw that line out as well.

The rest can all fit on a single line.

1

u/DatsLotus 4d ago

The more I learn, the more I discover I have more to learn.