What are some C++ related idioms, misconceptions, and gotchas that you've learnt from experience?

前端 未结 16 1810
刺人心
刺人心 2021-01-29 19:48

What are some C++ related idioms, misconceptions, and gotchas that you\'ve learnt from experience?

An example:

class A
{
  public: 
  char s[1024];
  cha         


        
16条回答
  •  一整个雨季
    2021-01-29 20:10

    Do not prefer to use shared_ptr unless needed. Prefer using C++ references and unique_ptr instead. shared_ptr is a performance hog and makes the code look more complex than it is. Normally this won't be an issue, except for the unusual attractiveness of shared_ptr and its contagious nature.

提交回复
热议问题