Language: C++

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

class Obj{
  private:
  	string name;
  	int sort;
  public:
  	void set_name(string n){
      this.name = n;
    };
  	string get_name(){
      return this.name;
    };
  	void set_sort(int i){
      this.sort = i;
    };
  	int get_sort(int i){
      return this.sort;
    };
}

int main(){
  int n;
  cin >> n;
  string s[n], p[n];
  Obj o[n];
  for(int i = 0; i < n; i++){
    cin >> s[i] >> p[i];
    s[i] = s[i] + " -" + p[i];
    o[i].set_name(s[i]);
    o[i].set_sort(i+1);
  }
  sort(o[0].name, o[n-1].name);
  for(int i = 0; i < n; i++){
    cout << o[i].get_sort << endl;
  }
  return 0;
}  
  


Compiler output:
a.cc:23:2: error: expected ';' after class definition
   23 | }
      |  ^
      |  ;
a.cc: In member function 'void Obj::set_name(std::string)':
a.cc:12:12: error: request for member 'name' in '(Obj*)this', which is of pointer type 'Obj*' (maybe you meant to use '->' ?)
   12 |       this.name = n;
      |            ^~~~
a.cc: In member function 'std::string Obj::get_name()':
a.cc:15:19: error: request for member 'name' in '(Obj*)this', which is of pointer type 'Obj*' (maybe you meant to use '->' ?)
   15 |       return this.name;
      |                   ^~~~
a.cc: In member function 'void Obj::set_sort(int)':
a.cc:18:12: error: request for member 'sort' in '(Obj*)this', which is of pointer type 'Obj*' (maybe you meant to use '->' ?)
   18 |       this.sort = i;
      |            ^~~~
a.cc: In member function 'int Obj::get_sort(int)':
a.cc:21:19: error: request for member 'sort' in '(Obj*)this', which is of pointer type 'Obj*' (maybe you meant to use '->' ?)
   21 |       return this.sort;
      |                   ^~~~
a.cc: In function 'int main()':
a.cc:36:13: error: 'std::string Obj::name' is private within this context
   36 |   sort(o[0].name, o[n-1].name);
      |             ^~~~
a.cc:8:16: note: declared private here
    8 |         string name;
      |                ^~~~
a.cc:36:26: error: 'std::string Obj::name' is private within this context
   36 |   sort(o[0].name, o[n-1].name);
      |                          ^~~~
a.cc:8:16: note: declared private here
    8 |         string name;
      |                ^~~~
a.cc:38:10: error: invalid use of non-static member function 'int Obj::get_sort(int)'
   38 |     cout << o[i].get_sort << endl;
      |     ~~~~~^~~~~~~~~~~~~~~~
a.cc:20:13: note: declared here
   20 |         int get_sort(int i){
      |             ^~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __cxx11::basic_string<char>; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:4772:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __cxx11::basic_string<char>]'
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:36:7:   required from here
   36 |   sort(o[0].name, o[n-1].name);
      |   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1906:50: error: no match for 'operator-' (operand types are 'std::__cxx11::basic_string<char>' and 'std::__cxx11::basic_string<char>')
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1906:50: note:   'std::__cxx11::basic_string<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1906:50: note:   'std::__cxx11::basic_string<char>' is not derived from 'const std::move_iterator<_IteratorL>'
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~