TAILIEUCHUNG - Lecture Data visualization - Chapter 11

This chapter presents the following content: Stale pointers and double delete, reference variables, reference type vs pointer type, structures, pointers to structures, exogenous vs indigenous data, shallow vs deep copying, linked lists, common errors. | Lecture 11 Recap Stale Pointers and Double Delete Reference Variables Reference Type vs Pointer Type Structures Pointers to Structures Exogenous vs Indigenous Data Shallow vs Deep Copying Linked Lists Common Errors Selective Questions from Exercise Q: Name and illustrate five operations that can be applied to pointers Answer: Pointers can be declared and initialized They can be assigned to point at an object They can be dereferenced They can be involved in arithmetic The address-of operator can be applied to a pointer in the same manner as any other object Q: Consider int a, b; int *ptr; / / A pointer int **ptrPtr; / / A pointer to a pointer ptr = &a; ptr Ptr = &ptr; a. Is this code legal? Answer: Yes b. What are the values of * ptr and * * ptrPtr ? Answer: Both have the same value as A Continued . c. Using no other objects besides those already declared, how can you alter ptrPtr so that it points at a pointer to b without directly touching ptr ? Answer: *ptrPtr=&b d. Is the following statement legal? ptrPtr = ptr ; Answer: No; these objects have different types. Q: a. Is *&x always equal to x? If not, give an example. Answer: Yes, as long as x is an object b. Is & *x always equal to x? If not, give an example. Answer: No, because x might not be a pointer Q: Is the following code legal? Why or why not? int a = 3; const int & b = a; Answer: This is perfectly legal. However if the const is moved from the second declaration to the first, then the declaration and initialization of b would be illegal. Q: What is wrong with omitting spacing in *x/ * y? Answer: /* begins a comment. Chapter 2 Objects and Classes Introduction In this chapter we will study how C++ uses the class to achieve encapsulation and information hiding; how classes are implemented; and several examples of classes, including classes used to manipulate rational numbers and strings Object-Oriented Programming Object-oriented programming appears to be emerging as the dominant paradigm At the heart of .

TÀI LIỆU MỚI ĐĂNG
10    179    3    29-12-2024
8    164    3    29-12-2024
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.