Is it true substituting structs with classes will generate or cause performance penalty in embedded systems dealing in areas where memory and efficiency are required The reason for asking this is due to the fact that i am experiencing a drop in performance after adding some new libraries. If structs and classes are practically the same then why i am getting a performance drop
Asked
Active
Viewed 51 times
1
-
1There's no such thing as "structs" in C++. There are only classes (and unions and built-in types.) `struct` is a keyword that can be used to declare and define classes. – juanchopanza May 05 '18 at 13:56
-
Related: https://stackoverflow.com/questions/92859/what-are-the-differences-between-struct-and-class-in-c Not sure if this question can simply be closed as a duplicate, or if this needs some citations to support "no, there's nothing more than that". – May 05 '18 at 13:56
-
2The only difference between `struct` and `class` is whether members default to private or public. This only affects visibility at compile time, it has no runtime implications at all. – Barmar May 05 '18 at 13:56
-
@juanchopanza this is a valid point but I struggled to understand why to this was happening in my scenario until i realized that some compilers old one do tend to this, If the platform is slow enough – Charles May 05 '18 at 14:46
-
Classes and structs are data structures, with different default access protections. They both can lead to better performance, they can contribute to execution slowness. You can't do one-performance-fits-all because the data structures will differ depending on their usage. A struct for a point is different than a struct for a USB packet. – Thomas Matthews May 05 '18 at 16:17