0

why was the need to create structure when we already had the concept of classes?And why is that they are passed in different ways?

  • 1
    Because classes are always allocated on the heap, which may be undesirable. Structs are values that exist "in-place" - which means no heap allocation, but imposes a load of restrictions (e.g. no inheritance, and complicating the CLR generics system...) – Dai Sep 03 '20 at 03:16
  • Does this answer your question? [What's the difference between struct and class in .NET?](https://stackoverflow.com/questions/13049/whats-the-difference-between-struct-and-class-in-net) – Dai Sep 03 '20 at 03:17
  • What programming language? In C++, class and structures can be passed both by reference and by value. – Raymond Chen Sep 03 '20 at 03:55

0 Answers0