Functions that take arrays an objects as arguments...
Hi all,
I learned C/C++ a long time ago in high school, and since then I have been working mainly in java. Now I am doing a C++ project again, and I have set up a system of classes and structures that interact with each other.
This involves several functions taking instances of a class (objects) as arguments, and also a few that take arrays as arguments or return arrays. Its a big complicated project, so I won't post all the code here. But suffice to say, I am getting a ton of errors mostly relating to taking objects or arrays as arguments when both defining a function and when calling that function. I have tried to fix these using pointers to objects/arrays instead, but have had limited success.
Lets say I want to define a function like this:
Code:
int myFunction(int* anArray, myClass anObject)
Should I do it like that, or with an asterick after myClass as well? And when I call the function, should it look like this:
Code:
int myNumbers[7];
int a;
myClass someObject(constructorArgument1);
a = myFunction(myNumbers, someObject);
Or should there be some more astericks or reference/deReference operators somewhere in the above code? Like I say, I have been working with Java for awhile, and I was never that great with pointers and stuff anyway.
Is there a site or tutorial that someone knows of that covers functions taking objects/arrays as arguments, or returning them, and when pointers are necessary to do this, and where the reference/dereference operators need to go? I have not found a tutorial that comprehensively covers all of this.
Thanks guys!