diff options
Diffstat (limited to 'Inclass- excersice- 10')
4 files changed, 25 insertions, 9 deletions
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 <iostream> #include "PointerExample.h" +#include <iostream> 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 <iostream> -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; } |