Try the fastest way to create flashcards
Question

Explain why memberwise assignment can cause problems with a class that contains a pointer member.

Solution

Verified
Answered 2 years ago
Answered 2 years ago

Memberwise assignment is when we copy the members of the first object to the second object using the operator =. Memberwise assignment can cause problems with a class that contains a pointer member because in this case the two instances of the class will contain separate pointers, with both pointers pointing to the same location in memory and therefore an error will occur.

Create a free account to view solutions

Create a free account to view solutions

Recommended textbook solutions

Fundamentals of Database Systems 7th Edition by Ramez Elmasri, Shamkant B. Navathe

Fundamentals of Database Systems

7th EditionISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe
948 solutions
Starting Out with C++: Early Objects 9th Edition by Godfrey Muganda, Judy Walters, Tony Gaddis

Starting Out with C++: Early Objects

9th EditionISBN: 9780134400242Godfrey Muganda, Judy Walters, Tony Gaddis
747 solutions
Introduction to Algorithms 3rd Edition by Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen

Introduction to Algorithms

3rd EditionISBN: 9780262033848Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
872 solutions
Introduction to Algorithms 4th Edition by Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen

Introduction to Algorithms

4th EditionISBN: 9780262046305Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
945 solutions

More related questions

1/4

1/7