C - C++ Arrays - Array of objects using new operator

#include<iostream>
#include<string>
using namespace std;
 
class forgetcode
{
public:
  string name;
 
  forgetcode()
  {
    cout<<"\nConstructor";
  }
 
  void display()
  {
    cout<<name;
  }
 
  void getstring(string st)
  {
    name=st;
  }
};
 
 
int main()
{
  forgetcode *f;
 
  try
  {
    f=new forgetcode[3];
  }
  catch (bad_alloc xa) 
  { 
    cout << "Allocation Failure\n"; 
    return 1; 
  } 
 
  f[0].getstring("c");
  f[1].getstring("c++");
  f[2].getstring("java");
 
  for(int i=0;i<3;i++)
  {
    cout<<"\nString"<<i<<":";
    f[i].display();
  }
 
  return 0;
}