TAILIEUCHUNG - Lecture note Data visualization - Chapter 10

In this chapter, the following content will be discussed: Pointer syntax in C++, null pointers, dynamic memory allocation, the new operator, garbage collection and delete operator. | Lecture 10 Recap Pointer Syntax in C++ Null Pointers Dynamic Memory Allocation The new Operator Garbage Collection and delete Operator Stale Pointers & Double Delete A problem may arise while using pointers that is an object may have several pointers pointing to it string *s = new string( "hello" ) ; / / s points at new string string *t = s; / / t points there, too delete t; / / The object is gone Assume these lines are scattered in a program as nobody write these lines of codes next to each other Prior to the call to delete, we have one dynamically allocated object that has two pointers pointing to it Continued . After the call to delete , values of s and t are unchanged They now are stale A stale pointer is a pointer whose value no longer refers to a valid object Dereferencing s and t can lead to unpredictable results Difficulty is that although t is obviously stale, the fact that s is stale is much less obvious, according to assumed situation Furthermore, in some situations, the .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.