GithubHelp home page GithubHelp logo

csc_122_dynamic_memory_allocation's Introduction

CSC 122 - Dynamic Memory Allocation

This project provides some code examples that compliment the slides for dynamic memory allocation in C++. The slides for the presentation can be found on my website. The slides go through making a little garden tracker app.

Setup

Currently, the Makefile only supports building and running the code via g++. If you want to build the code using another compiler, you will have to do so manually.

Each .cpp file is prefixed with a number indicating the step in the lesson. You can build and run a step of the lesson using:

make 1
make 2
make 3
make 4

Lesson Outline

1. Initial Garden Tracker

We start off by creating an array of strings with a hardcoded number of entries. Although this is simple to do, it does not provide us with the flexibility we need to create a dynamic list of plants.

2. Dynamic Memory Example

First, I use the new keyword in C++ to create an int and a string on the heap. Second, I print out the values and the memory addresses where they are stored. Finally, I use the delete keyword to return the memory to the heap.

3. Memory Leak

I purposefully implement an example of a memory leak. Notice that the program will probably run just fine on your system, even though memory is being leaked with each new creation of an int. Why is that?

4. Dynamic Array

I implement a dynamic array data structure using the heap. The garden tracker app can now hold any number of entries (assuming the system has enough memory)!

csc_122_dynamic_memory_allocation's People

Contributors

cmvandrevala avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.