Advertisement
mario_mos

mario_casts

Aug 31st, 2023 (edited)
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1.  #ifndef MERE_H
  2. #define MERE_H
  3.  
  4.  
  5. class mere
  6. {
  7. public:
  8.     mere();
  9.     virtual void print() = 0;
  10. };
  11.  
  12. #endif // MERE_H
  13.  
  14. #include "mere.h"
  15. #include <iostream>
  16.  
  17. mere::mere()
  18. {
  19.  
  20. }
  21.  
  22. #ifndef FILLE_H
  23. #define FILLE_H
  24. #include "mere.h"
  25.  
  26.  
  27. class fille : public mere
  28. {
  29. public:
  30.     fille();
  31.     void print();
  32. };
  33.  
  34. #endif // FILLE_H
  35. #include "fille.h"
  36. #include "mere.h"
  37. #include <iostream>
  38.  
  39. fille::fille()
  40. {
  41.  
  42. }
  43.  
  44. #include <iostream>
  45. #include "mere.h"
  46. #include "fille.h"
  47.  
  48. using namespace std;
  49.  
  50. int main()
  51. {
  52.     double i = 1.0;
  53.     static_cast<float>(i);
  54.  
  55.     mere* ptr_m1 = new fille();
  56.     fille* ptr_f1 = dynamic_cast<fille*>(ptr_m1);
  57.     ptr_f1->print();
  58.  
  59.     const int u = 100;
  60.     const int *pu = &u;
  61.     int *k=const_cast<int*>(pu);
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.     return 0;
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement