You have some errors:
In the template
sortByAtomicNumber
,std::array<int, N>
should bestd::array<Element, N>
.If you want call a function of a const object, the function must be const. So your
arr
is const reference, thevoid getElementName();
of theElement
class should bevoid getElementName() const;
.If you want call a non-const function of a object, the object must be non-const. So
template<size_t N> void sortByAtomicNumber(std::array<int, N> const& arr, int maximum, int minimum) { /* your code */ }
should betemplate<size_t N> void sortByAtomicNumber(std::array<Element, N>& arr, int maximum, int minimum) { /* your code */ }
, like @portforwardpodcast said.
Note: About the const function of const class, you can see this article. Hope that can help you.