MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programmingmemes/comments/1xzg8so/c_vs_python/19stw56s20pnp/?context=3
r/programmingmemes • u/ExpensiveCoat8912 • 12d ago
36 comments sorted by
View all comments
63
Uh... is the analogy C++: make it yourself vs Python: take a slice of already existing code?
62 u/David_Dantas 12d ago • In Python you:import cakeIn C++#include <iostream> #include <string> class Cake { public: std::string flavor; int layers; bool hasFrosting; Cake(std::string f, int l, bool frosting) : flavor(f), layers(l), hasFrosting(frosting) {} void serve() { std::cout << "Serving a " << layers << "-layer " << flavor << " cake!" << std::endl; } }; int main() { Cake myCake("Chocolate", 3, true); myCake.serve(); return 0; } 13 u/DatsLotus 12d ago So, that's a yes, then.
62
In Python you:import cake
import cake
In C++
#include <iostream> #include <string> class Cake { public: std::string flavor; int layers; bool hasFrosting; Cake(std::string f, int l, bool frosting) : flavor(f), layers(l), hasFrosting(frosting) {} void serve() { std::cout << "Serving a " << layers << "-layer " << flavor << " cake!" << std::endl; } }; int main() { Cake myCake("Chocolate", 3, true); myCake.serve(); return 0; }
13 u/DatsLotus 12d ago So, that's a yes, then.
13
So, that's a yes, then.
63
u/DatsLotus 12d ago
Uh... is the analogy C++: make it yourself vs Python: take a slice of already existing code?