Performance differences between structs and classes


I know the difference of structs and classes is that structs has its public members by default, and that structs belong to C (but nothing prevents from using in C ++).

In practice when creating an object for classes or a structure, who is the slowest? Which one will occupy more memory? Who has your fastest access?

asked by anonymous 20.12.2017 / 12:09

1 answer


In C ++ there is no difference other than the one already mentioned in the question, so there is no way to have any performance difference of any kind or memory consumption. They might have chosen not to have created the keyword class or could have created it by replacing struct , if it did not want to maintain compatibility with C. It would be the same.

20.12.2017 / 12:16