From 707a9cbb66934c22c1f1e89fd1506aad20356939 Mon Sep 17 00:00:00 2001 From: Jet Hughes Date: Mon, 5 Sep 2022 10:34:46 +1200 Subject: [PATCH] vault backup: 2022-09-05 10:34:46 --- content/notes/12-pointers-to-routines.md | 29 ++++++++++++++++++++++++ content/notes/cosc-204.md | 1 + 2 files changed, 30 insertions(+) diff --git a/content/notes/12-pointers-to-routines.md b/content/notes/12-pointers-to-routines.md index ecffb564a..249ce142a 100644 --- a/content/notes/12-pointers-to-routines.md +++ b/content/notes/12-pointers-to-routines.md @@ -4,6 +4,9 @@ aliases: tags: - cosc204 - lecture +sr-due: 2022-09-08 +sr-interval: 3 +sr-ease: 250 --- compiler ⇒ converts high level language description of program into assembly description of the program @@ -43,6 +46,7 @@ pointers to routines can beused anyqhere variables can ![|200](https://i.imgur.com/cwjCgBg.png) # modules + we can break programs into functional modules - each modules excapsulates one behaviour - give us a way of data hiding @@ -53,3 +57,28 @@ add pointer to structs as parameters to methods in modules - so that the implementation details are hidden ![queue ADT|400](https://i.imgur.com/pk2kOE2.png) + +method in this struct are "black box" + +we gain +- abstraction + - our queue has a print method, so could out stack, tree, and so on + - we call ob->print() without needing to know (exactly) which print method is called + +## constructor +creates object, initialises it and sets up function pointers +![constructor|400](https://i.imgur.com/HM6P3QI.png) + +## destructor +good to use. help with closing things and freeing memory + + +# modules overview +c programs consist of .c and .h files +- put ADT declarations in the .h (header) files + - we can `#include` these files if we want to use the ADT in a program +- put routine implementations in .c files + +## queue header +pragma says include only once: prevent include loops +![queue.h|400](https://i.imgur.com/gpcNZG0.png) diff --git a/content/notes/cosc-204.md b/content/notes/cosc-204.md index 8deb9ab7d..696d48c10 100644 --- a/content/notes/cosc-204.md +++ b/content/notes/cosc-204.md @@ -39,6 +39,7 @@ tags: - [07-6809-advanced](notes/07-6809-advanced.md) - [08-intro-to-c](notes/08-intro-to-c.md) - [11-struct-and-union](notes/11-struct-and-union.md) +- [12-pointers-to-routines](notes/12-pointers-to-routines.md) # Archive