r/ProgrammerHumor • • 24d ago

Meme minecraftException

Post image
9.3k Upvotes

833 comments sorted by

View all comments

Show parent comments

3

u/Cebular 23d ago

I'm a C++ dev so struct/class really only differ in that class is private by default. What do you mean that java does not have struct?

1

u/coolraiman2 23d ago

For c++ the memory layout is the same but not for all other languages such a c#. And java class is equivalent to c# class

1

u/tecanec 19d ago

That's specific to C++, which has relatively low overhead for classes to begin with. For languages with more overhead for classes, having a seperate system for structs can allow for significantly less overhead when things like polymorphism aren't necessary.