aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Inclass 10/Node.h2
-rw-r--r--Inclass 10/PointerExamples.cpp17
-rw-r--r--Inclass 10/program.cpp21
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