Andrew_Manu

Autos!

Jun 22nd, 2019
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Combustible{
  5.     private:
  6.         int litros;
  7.     public:
  8.         Combustible(int _litros);
  9.         ~Combustible();
  10.         void cargar(int c);
  11.         void consumir(int c);
  12.         int actual();
  13. };
  14. class Auto{
  15.     private:
  16.         int id;
  17.         string color, marca;
  18.     public:
  19.         Auto(int _id, string c, string m);
  20.         ~Auto();
  21.         bool estado = false;
  22.         void Avanzar();
  23.         void Prender();
  24.         void Apagar();
  25. };
  26.  
  27. Combustible::Combustible(int _litros){ litros = _litros }
  28.  
  29. Auto::Auto(int _id, string c, string m){
  30.     id = _id;
  31.     color = c;
  32.     marca = m;
  33.     cout << id << " " << color << " " << marca << endl;
  34. }  
  35. Auto::~Auto(){
  36.     cout << "Clase destruida" << endl;
  37.     system("pause>silvio");
  38. }
  39.  
  40. void Auto::Prender(){ estado = true; }
  41. void Auto::Apagar(){ estado = false; }
  42.  
  43. int main(int argc, char** argv){
  44.     {
  45.     Auto primerAuto = Auto(1, "Azul", "Ferrari");
  46.     Auto segundoAuto = Auto(2, "Rojo", "Ford");
  47.     }
  48.     Combustible primerTanque = Combustible(100);
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment