C++: Performance impact of BIG classes (with a lot of code)

前端 未结 9 2052
执念已碎
执念已碎 2021-01-17 15:08

I wonder if and how writing \"almighty\" classes in c++ actually impacts performance.

If I have for example, a class Point, with only uint x

9条回答
  •  天命终不由人
    2021-01-17 15:29

    You are right, methods only exist once in memory, they're just like normal functions with an extra hidden this parameter.

    And of course, only data members are taken in account for allocation, well, inheritance may introduce some extra ptrs for vptrs in the object size, but not a big deal

提交回复
热议问题