Which of the following can’t be used in memset?(多选)

阅读 54

2022-06-13

正确答案: A D 你的答案: A (错误)

  1. struct Parameters { int x; std::string str_x; };
  2. struct Parameters { int x; int* p_x; };
  3. struct Parameters { int x; int a_x[10]; };
  4. class BaseParameters{ public: virtual void reset() {} }; class
    Parameters : public BaseParameters{ public: int x; };

解析来了,A选项string对象中分配的堆内存,保存在string成员变量中,被memset后,该部分内存无法释放; D选项,类对象中有vptr指针,用memset会连vptr指针的值也清除。


精彩评论(0)

0 0 举报