c++使用类data排序问题怎么解

要求是用sort给数组中的10个数字排序,再用printf输出,需要自己编写的就是sort函数部分,小白太难了,试了很多次,还是有好多error和warning😭特来请教!

class data{
int a[10];
public:
data(int x[10])
{
for(int i=0;i<10;i++)
a[i]=x[i];
}
    {
        scanf("%d",&data[i]);
    }
    void sort() 
{
}
void print()
{ for(int i=0;i<10;i++)
       cout<<a[i]<<'\t';
       cout<<'\n';
ofstream outf("bc02.in"); 
for(i=0;i<10;i++)
outf<<a[i]<<'\t'; 
outf<<'\n'; 
outf.close();
}
};
void main()
    {
         int x[10]={2,1,4,45,23,33,-7,8,5,9};
         data d(x); 
         d.sort(); 
         d.print();

```}

#include <iostream>
#include <fstream>

class data {
    int a[10];

public:
    data(int x[10]) {
        for (int i = 0; i < 10; i++)
            a[i] = x[i];
    }

    void sort() {
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9 - i; j++) {
                if (a[j] > a[j + 1]) {
                    int temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                }
            }
        }
    }

    void print() {
        for (int i = 0; i < 10; i++)
            std::cout << a[i] << '\t';
        std::cout << '\n';

        std::ofstream outf("bc02.in");
        for (int i = 0; i < 10; i++)
            outf << a[i] << '\t';
        outf << '\n';
        outf.close();
    }
};

int main() {
    int x[10] = {2, 1, 4, 45, 23, 33, -7, 8, 5, 9};
    data d(x);
    d.sort();
    d.print();
    return 0;
}

#include <iostream>
using namespace std;

class data {
  int a[10];
public:
  data(int x[10]) {
    for(int i=0; i<10; i++)
      a[i] = x[i];
  }
  
  void sort() {
    for(int i=0; i<9; i++) {
      int min = i;
      for(int j=i+1; j<10; j++) {
        if(a[j] < a[min]) 
          min = j;
      }
      swap(a[i], a[min]);
    }
  }
  
  void print() {
    for(int i=0; i<10; i++)
      cout << a[i] << '\t';
    cout << '\n';
  }
};

int main() {
  int x[10]={2,1,4,45,23,33,-7,8,5,9};
  data d(x);
  d.sort();
  d.print();
  
  return 0;
}