aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraquelc <[email protected]>2024-03-21 19:06:03 -0700
committerraquelc <[email protected]>2024-03-21 19:06:03 -0700
commit6c4902294ceca6e50aa9116e1a78e459e14d1cc8 (patch)
treea03b331045e87808f92993f7046056c9abf80d3b
parentset up of files (diff)
downloadin-class-exercise-10-raquel191-6c4902294ceca6e50aa9116e1a78e459e14d1cc8.tar.xz
in-class-exercise-10-raquel191-6c4902294ceca6e50aa9116e1a78e459e14d1cc8.zip
commitHEADmain
-rw-r--r--Inclass- excersice- 10/Inclass- excersice- 10/Node.h3
-rw-r--r--Inclass- excersice- 10/Inclass- excersice- 10/PointerExample.cpp13
-rw-r--r--Inclass- excersice- 10/Inclass- excersice- 10/PointerExample.h5
-rw-r--r--Inclass- excersice- 10/Inclass- excersice- 10/program.cpp13
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;
}