Ho Chi Minh City University of Technology Faculty of Computer Science and Engineering
Data Structures and Algorithms – C++ Implementation
Huỳnh T n t
Email: firstname.lastname@example.org 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;
Faculty of Computer Science and Engineering – HCMUT Slide 2
On completion of this chapter students will know how to: Declare and initialize pointer variables, pass addresses to functions, return an address from a function, reserve memory during execution, link classes with accessor functions.
This chapter describes the fundamental characteristics of the objectoriented
C++ programming language. In addition, you will be introduced
to the steps necessary for creating a fully functional C++ program.The
examples provided will help you retrace these steps and also
demonstrate the basic structure of a C++ program.
Chapter 16 - Pointers and arrays. This chapter presents the following content: Declaring pointer variables, address vs. value, another need for addresses, executing the swap function, pointers as arguments, passing pointers to a function, code using pointers,...and other contents.
Chapter 19 - Data structures. After studying this chapter you will be able to understand: Structures in C, defining a struct, declaring and using a struct, defining and declaring at once, using typedef, generating code for structs, array of structs, pointer to struct,...
Pointers are the powerful feature of C and (C++) programming, which differs it from other popular programming languages like: java and Visual Basic. Pointers are used in C program to access the memory and manipulate the address. This chapter will introduce simple pointers, inviting you refer lecture for more details.
This module discusses arrays, strings, and pointers. Although these may seem to be three disconnected
topics, they aren’t. In C++ they are intertwined, and an understanding of one aids in the understanding
of the others.
An array is a collection of variables of the same type that are referred to by a common name. Arrays
may have from one to several dimensions, although the one-dimensional array is the most common.
Arrays offer a convenient means of creating lists of related variables.
The array that you will probably use most often is the character array, because it...
These notes are written based on the book The C Programming Language, by Brian Kernighan and Dennis Ritchie, or K&R (The second edition was published in 1988 by Prentice-Hall, ISBN 0-13-110362-8.). The sections are cross-referenced to those of K&R, for the reader who wants to pursue a more in-depth exposition.