Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include<iostream>
#include <math.h>
using namespace std;
class Figura {
private:
float base;
float altura;
public:
void captura();
virtual unsigned float perimetro()=0;
virtual unsigned float area()=0;
};
class Rectangulo: public Figura {
public:
void imprime();
unsigned float perimetro(){return 2*(base+altura);}
unsigned float area(){return base*altura;}
};
class Triangulo: public Figura {
public:
void muestra();
unsigned float perimetro(){return 2*sqrt(altura^2+(base/2)^2)+base;} //Usando pitágoras
unsigned float area(){return (base*altura)/2;}
};
void Figura::captura()
{
cout << "CALCULO DEL AREA Y PERIMETRO DE UN TRIANGULO ISÓSCELES Y UN RECTANGULO:" << endl;
cout << "escribe la altura: ";
cin >> altura;
cout << "escribe la base: ";
cin >> base;
cout << "EL PERIMETRO ES: " << perimetro();
cout << "EL AREA ES: " << area();
getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment