TAILIEUCHUNG - Absolute C++ (4th Edition) part 41

Absolute C++ (4th Edition) part 41. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | 406 Pointers and Dynamic Arrays Pointer Variable Declarations A variable that can hold pointers to other variables of type Type_Name is declared similar to the way you declare a variable of type Type_Name except that you place an asterisk at the beginning of the variable name. SYNTAX Type_Name Variable_Namei Variable_Name2 . . . Example double pointer1 pointer2 Addresses and Numbers A pointer is an address and an address is an integer but a pointer is not an integer. That is not crazy that is abstraction C insists that you use a pointer as an address and that you not use it as a number. A pointer is not a value of type int or of any other numeric type. You normally cannot store a pointer in a variable of type int. If you try most C compilers will give you an error message or a warning message. Also you cannot perform the normal arithmetic operations on pointers. As you will see later in this chapter you can perform a kind of addition and a kind of subtraction on pointers but they are not the usual integer addition and subtraction. dereferencing operator When discussing pointers and pointer variables we usually speak of pointing rather than speaking of addresses. When a pointer variable such as pl contains the address of a variable such as vl the pointer variable is said to point to the variable vl or to be a pointer to the variable vl. the operator Pointer variables like pl and p2 declared above can contain pointers to variables like vl and v2. You can use the operator to determine the address of a variable and you can then assign that address to a pointer variable. For example the following will set the variable pl equal to a pointer that points to the variable vl pl vl the operator You now have two ways to refer to vl You can call it vl or you can call it the variable pointed to by pl. In C the way you say the variable pointed to by pl is pl. This is the same asterisk that we used when we declared pl but now it has yet another meaning. When the asterisk is used .

TỪ KHÓA LIÊN QUAN
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.