This code is using Object Oriented Paradigm of C++ language and above code has a class named 'String' and all other functions are class member functions with some special cases of functions.
Above code creates a new user-defined data type just like pre defined data types 'int, double, float etc. . .' and overloads the assignment operation for the data type 'String' or you should say class.
If you do not know what is OOP, then you should first start OOP learning on this website.
The class has bugs. The constructor at line 38 doesn't initialize arr or len. The constructor at line 27 and the assignment operator at line 52 don't initialize a. These bugs mean that the main() that you've defined won't do what you expect:
1 2 3 4 5 6 7
int main()
{
String str; // str.num = 0
String bf(12); // bf.arr and bf.len uninitialized.
str=bf; // str gets the uninitialized bf.arr and bf.len, and doesn't get bf.num
cout<<str.num<<endl; // prints 0 because str.num is still 0 changed.
}
what should be written in the main body
The main() function is the one that runs when you execute the program. You haven't said what the program should do so I don't know what should be written there.