From 6c4902294ceca6e50aa9116e1a78e459e14d1cc8 Mon Sep 17 00:00:00 2001 From: raquelc Date: Thu, 21 Mar 2024 19:06:03 -0700 Subject: commit --- Inclass- excersice- 10/Inclass- excersice- 10/Node.h | 3 +++ .../Inclass- excersice- 10/PointerExample.cpp | 13 +++++++------ .../Inclass- excersice- 10/PointerExample.h | 5 +++++ Inclass- excersice- 10/Inclass- excersice- 10/program.cpp | 13 ++++++++++--- 4 files changed, 25 insertions(+), 9 deletions(-) (limited to 'Inclass- excersice- 10') diff --git a/Inclass- excersice- 10/Inclass- excersice- 10/Node.h b/Inclass- excersice- 10/Inclass- excersice- 10/Node.h index d59766b..af1f73f 100644 --- a/Inclass- excersice- 10/Inclass- excersice- 10/Node.h +++ b/Inclass- excersice- 10/Inclass- excersice- 10/Node.h @@ -1,6 +1,9 @@ #ifndef NODE_H #define NODE_H +struct Node { + int _num; +}; #endif diff --git a/Inclass- excersice- 10/Inclass- excersice- 10/PointerExample.cpp b/Inclass- excersice- 10/Inclass- excersice- 10/PointerExample.cpp index 5f3c920..db3fa3b 100644 --- a/Inclass- excersice- 10/Inclass- excersice- 10/PointerExample.cpp +++ b/Inclass- excersice- 10/Inclass- excersice- 10/PointerExample.cpp @@ -1,12 +1,13 @@ - -#include #include "PointerExample.h" +#include using std::cout; -using std::endl; - +void Swap(Node* first, Node* Second) { + int temp = 0; -int main() { + temp = first->_num; + first->_num = Second->_num; + Second->_num = temp; - return 0; + } \ No newline at end of file diff --git a/Inclass- excersice- 10/Inclass- excersice- 10/PointerExample.h b/Inclass- excersice- 10/Inclass- excersice- 10/PointerExample.h index 05c2909..d90d04c 100644 --- a/Inclass- excersice- 10/Inclass- excersice- 10/PointerExample.h +++ b/Inclass- excersice- 10/Inclass- excersice- 10/PointerExample.h @@ -1,7 +1,12 @@ #ifndef POINTER_EXAMPLE_H #define POINTER_EXAMPLE_H +#include "Node.h" +void Swap(Node* first, Node* Second); +void Standardize_101(Node* node); + +void Square(Node* node); diff --git a/Inclass- excersice- 10/Inclass- excersice- 10/program.cpp b/Inclass- excersice- 10/Inclass- excersice- 10/program.cpp index 88a208d..0c2c43a 100644 --- a/Inclass- excersice- 10/Inclass- excersice- 10/program.cpp +++ b/Inclass- excersice- 10/Inclass- excersice- 10/program.cpp @@ -6,15 +6,22 @@ #include "PointerExample.h" #include "Node.h" #include -using std::endl; -using std::cout; - +using namespace std; int main() { + Node first = {}; + first._num = 5; + + Node Second{}; + Second._num = 72; + + Swap(&first, &Second); + cout >> first._num; + return 0; } -- cgit v1.2.3