Объектно-ориентированное программирование. Сивохин А.В - 43 стр.

UptoLike

43
{gotoxy (x,y);
textattr (BLACK);
putch (' ');
visible=0;}
}
void TextPoint::Show (void)
{if (!visible)
{gotoxy (x,y);
textattr (color);
putch ('*');
visible=1;}
}
void TextPoint::Mov (int nx, int ny)
{ int was_visible=visible;
Hide();
if (nx<80) x=nx;
if (ny<25) y=ny;
if (was_visible) Show();
}
TextPoint TextPoint::operator ++ (int)
{Mov(x+1,y+1);
return (*this);
}
TextPoint TextPoint::operator -- (void)
{Mov(x-1,y-1);
return (*this);
}
TextPoint operator * (TextPoint &op1, int op2)
{ TextPoint temp (op1);
temp.x*=op2;
temp.y*=op2;
return temp;
}
//----------------------------------------------------------------
// Главный модуль, вызов методов класса
                                                                     43
    {gotoxy (x,y);
     textattr (BLACK);
     putch (' ');
     visible=0;}
}

void TextPoint::Show (void)
{if (!visible)
  {gotoxy (x,y);
   textattr (color);
   putch ('*');
   visible=1;}
}

void TextPoint::Mov (int nx, int ny)
{ int was_visible=visible;
  Hide();
  if (nx<80) x=nx;
  if (ny<25) y=ny;
  if (was_visible) Show();
}

TextPoint TextPoint::operator ++ (int)
{Mov(x+1,y+1);
 return (*this);
}

TextPoint TextPoint::operator -- (void)
{Mov(x-1,y-1);
 return (*this);
}

TextPoint operator * (TextPoint &op1, int op2)
{ TextPoint temp (op1);
  temp.x*=op2;
  temp.y*=op2;
  return temp;
}
//----------------------------------------------------------------
// Главный модуль, вызов методов класса