I can pass my array directly, but I need to know how to pass it by reference. I am using the new std :: array with type Element. I tried several things, but they do not work. I am not sure how to pass this as a link. I got it mixed up and I can't figure it out.
How to pass std :: array as a reference parameter to avoid copying the whole array?
How my array is configured:
std::array<Element, 115> Elements =
{{
{},
{1, 1.00794, period::PERIOD_ONE, group::HYDROGEN, metal::NONMETAL, shell::S_ORBITAL, "Hydrogen", "H"}
}};
AT
void sortByAtomicNumber(std::array<Element, 115> elements, int minimum, int maximum)
{
int counter = 1;
for(;minimum < (maximum+1); minimum++)
{
std::cout << counter << ".) " << elements[minimum].getElementName() << std::endl;
counter++;
}
}
Tried From: http://gauravpandey.com/wordpress/?p=602 // I have not yet studied the patterns ...
template<size_t N>
void sortByAtomicNumber(std::array<int, N> const& arr, int maximum, int minimum) {
int counter = 1;
for(;minimum < (maximum+1); minimum++)
{
std::cout << counter << ".) " << arr[minimum].getElementName() << std::endl;
counter++;
}
}
Error above
error: passing 'const value_type {aka const Element}' as the argument to 'this' from std :: string → Element :: getElementName ()' discards qualifiers [-fpermissive]