Đang chuẩn bị liên kết để tải về tài liệu:
Data Structures and Algorithms – C++ Implementation

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

BK TP.HCM Ho Chi Minh City University of Technology Faculty of Computer Science and Engineering BK TP.HCM Data Structures and Algorithms – C++ Implementation Huỳnh T n t Email: htdat@cse.hcmut.edu.vn Home Page: http://www.cse.hcmut.edu.vn/~htdat/ .Pointer in C++ Declaration Node *ptr; Create an object ptr = new Node(); A pointer usage printf(“Data in node: %d”, ptr-data); Destroy an object delete ptr; NULL pointer ptr = NULL; ??? ptr ptr ??? ptr ptr Faculty of Computer Science and Engineering – HCMUT Slide 2 .Pointer in C++ Be careful in these cases: Before ptr1 Before ptr1 ptr2 ptr1 = ptr2; ptr2 delete ptr1; ptr1 = NULL; Garbage After ptr1 After ptr1 ptr2 ptr2 Dangling reference problem Slide 3 Faculty of Computer Science and Engineering – HCMUT .Parameter Passing Techniques void func(int* a, int* b){ int *t;. | ỂBK Ho Chi Minh City University of Technology BK TP.HCM TP HCM Faculty of Computer Science and Engineering Data Structures and Algorithms -C Implementation Huỳnh Tấn Đạt Email htdat@cse.hcmut.edu.vn Home Page http www.cse.hcmut.edu.vn htdat Pointer in C Declaration Node ptr Create an object ptr new Node A pointer usage printf Data in node d Destroy an object delete ptr NULL pointer ptr NULL ptr ptr ptr- data ptr Faculty of Computer Science and Engineering - HCMUT Slide 2 Pointer in C Be careful in these cases Faculty of Computer Science and Engineering - HCMUT Slide