It has been a long time since I have used C++ (I am only 20, so maybe not that long) I have been using several languages in the last couple years(Java, ActionScript2 and 3, PHP), polluting my mind with many different idioms, and now need to hop back to C++.
Many questions have been coming to mind while I am trying to get back into the groove, and one thing that is causing some confusion is that functions pass arguments by value. This makes perfect sense for primitives, but I am getting lost in the semantics of pointers and references when it comes to structs and objects.
Now, arrays and pointers can be used "interchangeably", because an array IS a pointer to its first element (correct me if I am wrong). Is the same true of structs and objects?
Date dt = new Date();
myFunc1(dt);
myFunc2(dt);
myFunc3(&dt);
void myFunc1(Date d)
{}
void myFunc2(Date & d)
{}
void myFunc3(Date * d)
{}
So, if I am understanding correctly, when myFunc2 is invoked, it creates a Date reference and then assigns dt to the new reference(Constructor not called). Also the same for myFunc3, only we are using a pointer instead of a reference.
My confusion is in myFunc1. What is happening? If you pass by value, exactly what value does Date dt contain (a pointer?)? Is Date d a local copy of Date dt?
I am horribly comfortable with pass by reference. And for all intents and purposes, it seems that when you pass pointers and references, you are in essence passing by reference, although this reference is implicit, and is not a feature of the C++ framework (meaning it must be carefully managed, whereas in Java, there is no chance the object you reference will be unallocated or magically changed to another object)
If you can provide any insight into how structures and classes work internally, and how one goes about passing copies, references, and pointers to them.
Thanks for you time