Advertisement
ChristianBarzalobre

Constructor C++

Nov 28th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include<conio.h>
  2. #include<stdlib.h>
  3. #include<iomanip>
  4. using namespace std;
  5.  
  6. class operacion
  7. {
  8.     private: float w,x,y,z,res;
  9.    
  10.     public:
  11.    
  12.     void multi();
  13.     void mostrar();
  14.    
  15.     operacion(float num1=0.0, float num2=0.0, float num3=8.2, float num4=6.2);
  16.     ~operacion(){};
  17.        
  18. }op1;
  19.  
  20. operacion::operacion(float num1, float num2, float num3, float num4)
  21. {
  22.     w=num1; x=num2; y=num3; z=num4;
  23. }
  24.  
  25. void operacion::multi()
  26. {
  27.     cout<<"\n\nIntroduce valores con decimales";
  28.     cout<<"\n\nIngresa el valor de w: ";
  29.     cin>>w;
  30.     cout<<"\nIngresa el valor de x: ";
  31.     cin>>x;
  32.        
  33.     res=(w*x*y*z);
  34.     cout<<"\n\n----------------------------------------------";
  35.     cout<<"\nEl resultado de la multiplicacion es: "<<res;
  36.     cout<<"\n----------------------------------------------";
  37. }
  38.  
  39. void operacion::mostrar()
  40. {
  41.     cout<<"\n\n Valores Inicializados";
  42.     cout<<"\n\n w="<<w;
  43.     cout<<"\n x="<<x;
  44.     cout<<"\n y="<<y;
  45.     cout<<"\n z="<<z;
  46. }
  47.  
  48.  
  49. main()
  50. {
  51.     system("color 1f");
  52.     op1.mostrar(); 
  53.     op1.multi();   
  54.     getch();
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement