1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #include <iostream.h> class nombre{ protected : int entier; public : nombre( int ent); virtual void affiche_nombre(); }; class hexa: public nombre{ public : hexa( int ent); void affiche_nombre(); }; class octal:nombre{ public : octal( int ent); void affiche_nombre(); }; class decimal:nombre{ public : decimal( int ent); void affiche_nombre(); }; nombre::nombre( int ent){ entier=ent; } void nombre::affiche_nombre(){ cout<< "voici le nombre : " <<entier<<endl; } hexa::hexa( int ent):nombre(ent){} void hexa::affiche_nombre(){ cout << " le nombre en hexa est de : " <<hex<<entier<<endl; } octal::octal( int ent):nombre(ent){} void octal::affiche_nombre(){ cout << " le nombre en octal est de : " <<oct<<entier<<endl; } decimal::decimal( int ent):nombre(ent){} void decimal::affiche_nombre(){ cout << " le nombre en décimal est de : " <<dec<<entier<<endl; } void main(){ nombre a(12); a.affiche_nombre(); decimal b(12); b.affiche_nombre(); octal c(12); c.affiche_nombre(); hexa d(12); d.affiche_nombre(); } |
- Saturday
- May 17th, 2025
- Ajouter un cours