/*********************************************************** T.A.D. : Cercle Analyse Un cercle est connu par son rayon Les formules necessaires sont: perimetre = 2r surface = r2 **************************************************************/ #include #include using namespace std; const float PI = 3.14159 ; class Cercle { float rayon ; public: Cercle() ; Cercle(float) ; void lecture(istream&); void imprime(ostream&) ; float perimetre() ; float surface() ; string en_string(); } ; /***************************************************************** Methodes pour le type Cercle *****************************************************************/ /*--------------------------------------------------------------- Contructeurs ---------------------------------------------------------------*/ Cercle::Cercle() { rayon = 0 ; } Cercle::Cercle(float valeur_rayon) { rayon = valeur_rayon ; } /*--------------------------------------------------------------- Lecture ---------------------------------------------------------------*/ // De l'entree standard (clavier) void Cercle::lecture(istream& in) { in >> rayon ; } /*--------------------------------------------------------------- Methode pour le calcul... ---------------------------------------------------------------*/ float Cercle::perimetre() { return 2 * PI * rayon ; } float Cercle::surface() { return PI * rayon * rayon ; } /*--------------------------------------------------------------- Ecriture ---------------------------------------------------------------*/ // Sur la sortie standard (ecran) void Cercle::imprime(ostream& out) { out << rayon ; } istream& operator>>(istream& is, Cercle& rd) { rd.lecture(is); return is; } ostream& operator<<(ostream& os, Cercle rd) { rd.imprime(os); return os; }