Any performance reason to put attributes protected/private?

后端 未结 3 763
不思量自难忘°
不思量自难忘° 2021-01-06 03:43

I \"learned\" C++ at school, but there are several things I don\'t know, like where or what a compiler can optimize, seems I already know that inline and

3条回答
  •  广开言路
    2021-01-06 04:22

    There's no such thing as public, private and protected once your code is compiled, so it cannot affect performance.

    There's also no such thing as const in machine code (except perhaps ROM), but the compiler can make some logical optimisations to your program by knowing whether a value can change (in some situations).

    inline rarely has any effect. It is merely a suggestion to the compiler, which the compiler is free to ignore (and often does). The compiler will inline functions as it sees fit.

提交回复
热议问题