diff options
| author | Connor McDowell <[email protected]> | 2024-02-08 15:55:18 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-08 15:55:18 -0800 |
| commit | 2049a2c87f64bc3c4f9db66ceac0bac44ccb8b99 (patch) | |
| tree | 7632866bc847ba8d66d86ce6c21d1e73851fc7e5 | |
| parent | files and functions set up (diff) | |
| download | in-class-exercise-10-connormcdowell275-2049a2c87f64bc3c4f9db66ceac0bac44ccb8b99.tar.xz in-class-exercise-10-connormcdowell275-2049a2c87f64bc3c4f9db66ceac0bac44ccb8b99.zip | |
i literally have NO idea what to do. all i get is the addresses when the assignment is asking for the _num values to be swapped BUT NUM ISNT EVEN PART OF THE FUCKING STRUCTS
| -rw-r--r-- | Inclass 10/Node.h | 2 | ||||
| -rw-r--r-- | Inclass 10/PointerExamples.cpp | 17 | ||||
| -rw-r--r-- | Inclass 10/program.cpp | 21 |
3 files changed, 24 insertions, 16 deletions
diff --git a/Inclass 10/Node.h b/Inclass 10/Node.h index 8c11984..abfe605 100644 --- a/Inclass 10/Node.h +++ b/Inclass 10/Node.h @@ -5,7 +5,7 @@ struct Node { - int _data; + int data; Node* next; }; diff --git a/Inclass 10/PointerExamples.cpp b/Inclass 10/PointerExamples.cpp index 4889659..16de9c3 100644 --- a/Inclass 10/PointerExamples.cpp +++ b/Inclass 10/PointerExamples.cpp @@ -8,19 +8,24 @@ using std::endl; void Swap(Node* first, Node* second) { + int test = 0; + int test2 = 0; + first->data = test; + second->data = test2; + cout << "first node swapped is (correct 16): " << second << " the second node swapped is (correct 24): " << first << endl; +} -} - -void Standardize_101(Node* node) +void Standardize_101(Node* thirdNode) { - - + /*int stan = 0; + Node* thirdNode = stan; + thirdNode->_data = stan;*/ } -void Square(Node* node) +void Square(Node* thirdNode) { diff --git a/Inclass 10/program.cpp b/Inclass 10/program.cpp index d3f8005..59231d5 100644 --- a/Inclass 10/program.cpp +++ b/Inclass 10/program.cpp @@ -13,20 +13,23 @@ using std::endl; int main() { - Node firstNode{}; - Node secondNode{}; - Node thirdNode{}; + Node newNode{}; - firstNode._data = 24; - secondNode._data = 16; - thirdNode._data = 4; + newNode.data = 32; + cout << newNode.data << endl; - Swap(&firstNode, &secondNode); + Node nextNode{}; - Standardize_101(&thirdNode); + nextNode.data = 438; - Square(&thirdNode); + newNode.next = &nextNode; + + Swap(&newNode, &nextNode); + + Standardize_101(&newNode); + + Square(&nextNode); return 0; }
\ No newline at end of file |