Link to home
Start Free TrialLog in
Avatar of CucumberBilly
CucumberBilly

asked on

How do you pass a C++ array element by reference?

How do you pass an individual C++ array element by reference?  Is this possible?

Suppose you have the following class and array.  How would you pass an element of that array into some function while changing the actual element of that array as well as the members of that class instance?

class MyClass
{
     public:
          int member1;
          int member2;
          float member3;
};

MyClass myClassArray[ 10 ];

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CucumberBilly
CucumberBilly

ASKER

Thanks, I didn't realize you could use the same reference operator in a function for array elements.
A single array element is both semantically and syntactically identical to its scalar counterpart.