Estructura círculo

Aquí se define la estructura círculo. Tiene un radio, coordenadas de su centro y un área.

=============================== Código ================================

struct circulo : FiguraGeom{
float x,y,r;

circulo(){  //Constructor
x=0;
y=0;
r=0;
area=0.0;
}
circulo(float xx, float yy, float rr){  //Constructor
x = xx;
y = yy;
r = rr;
area = 3.1416*r*r;
}
void muestra(){
cout << “Circulo: (“<<x<<“,”<<y<<“;”<<r<<“,”<<area<<“)”<<endl;
}
friend istream& operator >> (istream& is, circulo &c){             //Formato de salida
char coma;
cout <<“Introducir valores en formato x,y,r: “;
is >>c.x>>coma>>c.y>>coma>>c.r;
return is;
}
};

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s