aboutsummaryrefslogtreecommitdiff
path: root/Inclass-9/ReferenceExamples.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Inclass-9/ReferenceExamples.cpp')
-rw-r--r--Inclass-9/ReferenceExamples.cpp36
1 files changed, 36 insertions, 0 deletions
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