aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-02-08 12:15:38 -0800
committerConnor McDowell <[email protected]>2024-02-08 12:15:38 -0800
commit672a0bc2400b51e57e6d73142cfa76010255a72c (patch)
tree283d6be9755949e81c7436859c5acf51ab5dea94
parent.cpp and .h files set up, labled, and included. (diff)
downloadin-class-exercise-9-connormcdowell275-672a0bc2400b51e57e6d73142cfa76010255a72c.tar.xz
in-class-exercise-9-connormcdowell275-672a0bc2400b51e57e6d73142cfa76010255a72c.zip
gone through some of the lecture, includes node and basic ref
-rw-r--r--Inclass-9/Program.cpp47
-rw-r--r--Inclass-9/ReferenceExamples.cpp23
-rw-r--r--Inclass-9/ReferenceExamples.h6
3 files changed, 73 insertions, 3 deletions
diff --git a/Inclass-9/Program.cpp b/Inclass-9/Program.cpp
index 9942f85..b408bad 100644
--- a/Inclass-9/Program.cpp
+++ b/Inclass-9/Program.cpp
@@ -8,4 +8,49 @@
using std::cin;
using std::cout;
-using std::endl; \ No newline at end of file
+using std::endl;
+
+void basicreferences()
+{
+ int variable = 15;
+
+ int& ref = variable;
+
+ int* address = &variable;
+
+ ref++;
+
+ cout << variable << endl;
+
+ cout << address << endl;
+}
+
+struct node
+{
+ int data;
+
+};
+
+void DoublesNodeData(node node)
+{
+ node.data *= 2;
+}
+void DoublesNodeDataRef(node& node)
+{
+ node.data *= 2;
+}
+
+int main()
+{
+ //basicreferences();
+ node newNode = {};
+
+ newNode.data = 32;
+
+ DoublesNodeDataRef(newNode);
+
+ cout << newNode.data << endl;
+
+ return 0;
+}
+
diff --git a/Inclass-9/ReferenceExamples.cpp b/Inclass-9/ReferenceExamples.cpp
index aaef1d6..bd90626 100644
--- a/Inclass-9/ReferenceExamples.cpp
+++ b/Inclass-9/ReferenceExamples.cpp
@@ -5,4 +5,25 @@
using std::cin;
using std::cout;
-using std::endl; \ No newline at end of file
+using std::endl;
+
+void Swap(int& x, int& y)
+{
+
+
+
+}
+
+void Standardize_101(int& n)
+{
+
+
+ // return n %= 101;
+}
+
+void Square(int& x)
+{
+
+
+
+} \ No newline at end of file
diff --git a/Inclass-9/ReferenceExamples.h b/Inclass-9/ReferenceExamples.h
index 5c679d5..a5c5ce0 100644
--- a/Inclass-9/ReferenceExamples.h
+++ b/Inclass-9/ReferenceExamples.h
@@ -1,7 +1,11 @@
#ifndef HEADER
-#def HEADER
+#define HEADER
+void Swap(int& x, int& y);
+void Standardize_101(int& n);
+
+void Square(int& x);