Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. // ConsoleApplication19.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. /*int main()
  10. {
  11. cout<<"Hello World";
  12.  
  13. return 0;
  14. }*/
  15.  
  16. class A {
  17. public:
  18. virtual int fun() {
  19. cout << "A"; return 0;
  20. }
  21. int fun1() {
  22. return fun();
  23. }
  24. ~A() {
  25. fun();
  26. }
  27. };
  28. class B : public A {
  29. public:
  30. int fun() {
  31. cout << "B"; return 0;
  32. }
  33. int fun2() {
  34. return fun();
  35. }
  36. };
  37. char abecadlo[] = "przeintelektualizowany";
  38. class Y {
  39. public:
  40. static int nn;
  41. Y() {
  42. cout << abecadlo[nn % 20] << "~";
  43. }
  44. Y(int nn) {
  45. Y::nn += nn;
  46. }
  47. virtual ~Y() {
  48. nn--;
  49. }
  50. };
  51. class X : public Y{
  52. int n;
  53. X *p;
  54. Y q;
  55. public:
  56. X(int nn) : n(nn),p(0),q(nn) {
  57. if (n % 2)
  58. p = new X(n - 1);
  59. cout << abecadlo[(n + nn) % 10];
  60. }
  61. ~X() {
  62. cout << nn;
  63. if (p) delete p;
  64. }
  65. };
  66. int Y::nn = 107416;
  67. int main() {
  68. Y* x = new X(5);
  69. delete x;
  70. B* b = new B;
  71. b->fun1();
  72. b->fun2();
  73. delete b;
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement