#include <iostream>
#include <math.h>

char *strdup(const char *str)
  {
   int len=strlen(str)+1;
   char *wynik=new char[len];
   memcpy(wynik,str,len);
   return wynik;
  }

class Punkt
  {
   public:
   double x,y;
   Punkt():x(0),y(0) {}
   Punkt(double x,double y):x(x),y(y) {}
   double operator-(const Punkt &P)const;
  };

double Punkt::operator-(const Punkt &P)const
  {
   double dx=P.x-x,dy=P.y-y;
   return sqrt(dx*dx+dy*dy);
  }
  
ostream &operator<<(ostream &s,const Punkt &P)
  {
   return s<<'('<<P.x<<','<<P.y<<')';
  }

class Miasto:public Punkt
  {
   char *Nazwa;
   public:
   //Miasto():Puinkt(),Nazwa(0) {}
   Miasto(const char *Nazwa):Punkt(),Nazwa(strdup(Nazwa)) {}
   Miasto(const Miasto &M,double x,double y):Punkt(x,y),Nazwa(strdup(M.Nazwa)) {}
   Miasto(const Miasto &M):Punkt(M),Nazwa(strdup(M.Nazwa)) {}
   ~Miasto() { delete[] Nazwa; }
   const char *nazwa()const { return Nazwa; }
  };

ostream &operator<<(ostream &s,const Miasto &M)
  {
   return s<<'('<<M.x<<','<<M.y<<')'<<' '<<M.nazwa();
  }

int main()
  {
   Miasto M("warszawa");
   
   cout<<M<<endl;
   
   cin.get();
   return 0;
  }


