From 3dc13cf69c1e788653b6a090ee0a97a68fe9c781 Mon Sep 17 00:00:00 2001 From: Connor McDowell Date: Thu, 8 Feb 2024 12:31:32 -0800 Subject: int main for practice and examples commented, functions moved to Reference Examples --- Inclass-9/ReferenceExamples.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'Inclass-9/ReferenceExamples.cpp') 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 -- cgit v1.2.3