首页> 外文期刊>SIGCSE bulletin >The Treatment of Deep vs. Shallow Copy in Introductory C++ Textbooks
【24h】

The Treatment of Deep vs. Shallow Copy in Introductory C++ Textbooks

机译:入门C ++教科书中的深层复制与浅层复制的处理

获取原文
获取原文并翻译 | 示例

摘要

The default behavior of C++ compilers is to generate a destructor, copy constructor, and assignment operator for each class defined in source code, if that class does not provide such. The constructor and assignment operator generated perform a shallow copy of objects, which is incorrect behavior for most objects that contain pointers. Students must be taught to provide these operators, and to write the copy constructor and assignment operator such that they perform a deep copy of objects. A survey of introductory C++ texts shows that some authors do not explain this important topic in a consistent or thorough way. Any instructor beginning to teach C++ needs to understand this or face the prospect of long hours debugging what otherwise would seem to be a straightforward assignment.
机译:C ++编译器的默认行为是为源代码中定义的每个类生成析构函数,复制构造函数和赋值运算符(如果该类未提供此类的话)。生成的构造函数和赋值运算符执行对象的浅表复制,这对于大多数包含指针的对象而言是不正确的行为。必须教导学生提供这些运算符,并编写复制构造函数和赋值运算符,以便他们执行对象的深层复制。对C ++入门书籍的调查显示,一些作者没有以一致或彻底的方式解释这个重要的主题。任何开始教C ++的讲师都必须了解这一点,否则将面临长时间调试的前景,否则这似乎是一件简单的事情。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号