| The treatment of deep vs. shallow copy in introductory C++ textbooks |
| Full text |
Pdf
(285 KB)
|
| Source
|
ACM SIGCSE Bulletin
archive
Volume 35 , Issue 2 (June 2003)
table of contents
COLUMN: Reviewed papers
table of contents
Pages: 99 - 102
Year of Publication: 2003
ISSN:0097-8418
|
|
Author
|
|
| Publisher |
|
| Bibliometrics |
Downloads (6 Weeks): 5, Downloads (12 Months): 68, Citation Count: 0
|
|
|
ABSTRACT
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.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
| |
1
|
|
| |
2
|
Owen L. Astrachan. A Computer Science Tapestry. 2/e, McGraw-Hill, 2000.
|
| |
3
|
James P. Cohoon and Jack W. Davidson. C++ Program Design. 3/e, McGraw-Hill, 2002.
|
| |
4
|
Deitel and Deitel. C++ How to Program. 3/e, Prentice Hall, 2001.
|
| |
5
|
|
| |
6
|
|
| |
7
|
Jo Ellen Perry and Harold D. Levin. An Introduction to Object-Oriented Design in C++. Addison-Wesley, 1996.
|
| |
8
|
|
| |
9
|
|
Peer to Peer - Readers of this Article have also read:
-
Data structures for quadtree approximation and compression
Communications of the ACM
28, 9
Hanan Samet
-
A hierarchical single-key-lock access control using the Chinese remainder theorem
Proceedings of the 1992 ACM/SIGAPP Symposium on Applied computing
Kim S. Lee
, Huizhu Lu
, D. D. Fisher
-
The GemStone object database management system
Communications of the ACM
34, 10
Paul Butterworth
, Allen Otis
, Jacob Stein
-
Putting innovation to work: adoption strategies for multimedia communication systems
Communications of the ACM
34, 12
Ellen Francik
, Susan Ehrlich Rudman
, Donna Cooper
, Stephen Levine
-
An intelligent component database for behavioral synthesis
Proceedings of the 27th ACM/IEEE Design Automation Conference on
Gwo-Dong Chen
, Daniel D. Gajski
|