I am having trouble understanding how to access the struct. This is exactly how this part of the code is supposed to look according to the assignments but i feel like it is not 100% correct. The Read member seems to be getting errors.
I tried doing this in the main in order to have an array of 6 intergers and have it displayed using the persons name.
Such as "John this is your array": 1 2 3 4 5 6
But it didn't work. The struct within the private is really confusing me. Any help would be appreciated.
#include <iostream>
#include <string>
#include <algorithm>
usingnamespace std;
template<class T, int n>
class SIX {
private:
struct BOX{
T a[n];
string Name;
};
public:
void Read()
{
cout<<"Enter your name:";
cin>>Name;
cout<<Name<<"Please enter"<<n<<" data:";
for (int i=0; i<n; ++i)
cin>>a[i];
}
void SortArray(){
sort(a, a+n);
}
void Display(){
cout<<Name<<"this is the sorted list of data in your array a\n";
for(int i=0;i<n;++i)
cout<<a[i]<<"\t";
cout<<endl;
}
};
int main()
{
}