Join Bill Weinman for an in-depth discussion in this video Dynamic memory operators, part of C++ Essential Training.
- [Bill] The new and delete operators…are used to allocate and free memory in C++.…These operators are specific to C++…and are not available in C.…Here I have a working copy of new-delete.cpp…from chapter four of the exercise files…and you notice that here on line seven…I have a constant expression…with the value 1,024 of type size_t…and we're going to use this for allocating space…with new, and down here I have a long integer pointer…and so ip is a pointer to a long int type…and here I have what's called a try catch block…which is for catching an exception…and we'll talk about that in a minute.…
But inside the try part of it,…I am allocating space for count, long integers…and I'm doing this with the new operator…and so I pass new the type,…and inside square brackets is the count…and if I were to not include the square brackets…and the count it would simply allocate space…for one object of that size…and so this is allocating space for 1,024 objects…of the type long int, and then down here I initialize…all those 1,024 long ints to sequential numbers…
Author
Released
12/19/2018- Setting up Xcode and Visual Studio
- Statements and expressions
- Variables
- Primitive arrays and strings
- Conditionals
- Loops
- Data types
- Operators
- Functions
- Classes and objects
- Templates
- Standard Library and Standard Template Library
Skill Level Intermediate
Duration
Views
Related Courses
-
Learning C++
with Erin Colvin2h 26m Beginner -
Learning C++ Pointers
with Peggy Fisher53m 55s Intermediate -
Learning C++ (2014)
with Peggy Fisher2h 36m Beginner
-
Introduction
-
About this course1m 2s
-
Using the exercise files1m 10s
-
What is C++?4m 7s
-
-
1. Installation
-
2. Basic Syntax
-
Anatomy of a C++ program8m 43s
-
Statements and expressions3m 23s
-
Identifiers2m 23s
-
Defining variables3m 6s
-
Pointers4m 29s
-
References3m 27s
-
Primitive arrays3m 11s
-
Primitive strings3m 58s
-
Conditionals5m 6s
-
The branching conditional2m 55s
-
Iterating with for4m 42s
-
Range-based for loop3m 41s
-
Using stdout6m 58s
-
3. Data Types
-
Overview of data types3m 9s
-
Integer types2m 26s
-
Integer sizes6m 7s
-
Fixed-size integers4m 7s
-
Floating point types5m 41s
-
Characters and strings3m 53s
-
Character-escape sequences3m 40s
-
Qualifiers6m 1s
-
References5m 43s
-
Structured data2m 23s
-
Bit fields2m 45s
-
Enumerations3m 55s
-
Unions2m 47s
-
Defining types with typedef2m 22s
-
The void type2m 23s
-
The auto type3m 24s
-
-
4. Operators
-
Common operators2m 54s
-
Logical operators2m 17s
-
Bitwise operators3m 29s
-
Ternary conditional operator1m 47s
-
Dynamic memory operators7m 14s
-
Type cast3m 14s
-
Using sizeof4m
-
Using typeid2m 44s
-
Operator precedence2m 13s
-
-
5. Functions
-
Overview of C++ functions3m 32s
-
Creating a function3m 20s
-
Passing values to a function6m 13s
-
Using function pointers6m 22s
-
-
6. Classes and Objects
-
Defining a class3m 32s
-
Data members3m 56s
-
Function members6m 44s
-
Constructors and destructors6m 10s
-
Overloading operators6m 34s
-
7. Templates
-
Understanding templates2m 48s
-
Template functions4m 42s
-
Template classes3m 42s
-
-
8. Standard Library
-
File I/O4m 45s
-
Binary files4m 22s
-
File management4m 11s
-
Unformatted character I/O5m 57s
-
Formatted character I/O3m 34s
-
String functions5m 2s
-
Handling system errors2m 33s
-
9. Standard Template Library (STL)
-
Overview of the STL2m 25s
-
Vectors3m 56s
-
Strings3m 33s
-
I/O streams8m 3s
-
Handling exceptions4m 22s
-
-
Conclusion
-
Thank you1m 30s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Dynamic memory operators