aboutsummaryrefslogtreecommitdiff
path: root/Inclass-9
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-02-08 12:31:32 -0800
committerConnor McDowell <[email protected]>2024-02-08 12:31:32 -0800
commit3dc13cf69c1e788653b6a090ee0a97a68fe9c781 (patch)
tree6b397f57c0ac1a8f5b42d1b6055191f450d77a95 /Inclass-9
parentgone through some of the lecture, includes node and basic ref (diff)
downloadin-class-exercise-9-connormcdowell275-3dc13cf69c1e788653b6a090ee0a97a68fe9c781.tar.xz
in-class-exercise-9-connormcdowell275-3dc13cf69c1e788653b6a090ee0a97a68fe9c781.zip
int main for practice and examples commented, functions moved to Reference Examples
Diffstat (limited to 'Inclass-9')
-rw-r--r--Inclass-9/Program.cpp33
-rw-r--r--Inclass-9/ReferenceExamples.cpp36
2 files changed, 42 insertions, 27 deletions
diff --git a/Inclass-9/Program.cpp b/Inclass-9/Program.cpp
index b408bad..5b7fa73 100644
--- a/Inclass-9/Program.cpp
+++ b/Inclass-9/Program.cpp
@@ -10,46 +10,25 @@ using std::cin;
using std::cout;
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();
+ /*basicreferences();
node newNode = {};
newNode.data = 32;
- DoublesNodeDataRef(newNode);
+ //DoublesNodeData(&newNode);
+
+ cout << newNode.data << endl;*/
+
+
- cout << newNode.data << endl;
return 0;
}
diff --git a/Inclass-9/ReferenceExamples.cpp b/Inclass-9/ReferenceExamples.cpp
index bd90626..30be619 100644
--- a/Inclass-9/ReferenceExamples.cpp
+++ b/Inclass-9/ReferenceExamples.cpp
@@ -26,4 +26,40 @@ void Square(int& x)
+}
+
+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;
+}
+
+void DoublesNodeData(node* node)
+{
+ node->data *= 2;
} \ No newline at end of file