1. Список говнокодов пользователя KARTON

    Всего: 1

  2. C++ / Говнокод #21408

    −22

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    #include <iostream>
    using namespace std;
    
    class cs{protected: int t;int fs(){return t;}   cs(int p):t(p){} ~cs(){cout<<"\n~cs"<<this;} friend void sh(cs*);};
    
    class cn:protected cs {protected: int t  /* ,z */ ; cn(int p, int ps):cs(ps), t(p){} int fs(){return t+cs::fs();}};
    
    class ct:protected cn, protected cs {protected: int t;int fs(){return t+cs::fs()+cn::fs();} friend int sm( ct*  x){return x->fs();}
    friend void sh(ct*);
    public: ct(int p, int ps, int pns, int pn):cs(ps), t(p), cn(pn,pns){} //void setZ(int pz){z=pz;} int getZ(){return z;}
    		~ct(){cout<<"\n~ct";}};
    
    void sh(ct* x){cout <<endl<<x<<' '<<x->t<<' '<<x->cs::t<<' '<<x->cn::t<<' '<<x->cn::cs::t;}
    
    void shcs(cs* x){ cout <<endl<<x; sh(x);}
    void sh(cs* x){cout <<endl<<x<<' '<<x->t;}
    
    struct ss {int t;ss(int p):t(p){}  void sh(){cout<<"\nsst="<<t;}~ss(){cout<<"\n~ss"<<this<<' '<<sizeof(*this);}};// no distructor for *this
    
    struct sn: ss { int t; sn(int p, int ps):ss(ps), t(p){} };
    
    struct st: sn,  ss { int t; st(int p, int ps, int pns, int pn):ss(ps), t(p), sn(pn,pns){}  ~st(){cout<<"\n~st"<<' '<<sizeof(*this);}};
    
    void main()
    {
    	ct* pct = new ct(1,2,4,8);cout <<sm(pct);
    //	pct->setZ(77);cout <<pct->getZ()<<endl;
    
    	for (int t= sizeof(*pct)/sizeof(int) ,sm=0, *pi=(int*)pct;t--; sm+= *pi++,cout<<' '<<sm);//4 12 14
    
    	cout<<"\ncalling shcs";sh(pct);shcs((cs*)pct);shcs((cs*)(cn*)pct);
    
    	delete pct;
    
    
    	st* pst = new st(1,2,4,8);
    	sn* psn=0;
    	ss* pss;  cout <<"\n ss* ->t="<<(pss /*  = psn  */ = pst)->t<<' '<<pss<<' '<<psn<<' '<<' '<<pst; // different pss' addresses 
    	cout <<"\n ss* ->t="<<(pss=(sn*)pst)->t<<' '<<pss<<' '<<pst;
    
    	st* ps2= (st*)pss; cout<<"\nst* ps2 = (st*) pss"<<ps2;// not existing instant on that address - CAN CRASH!!!
    
    	/* pss=pst; */  delete /*(st*)(sn*)*/  pss;//??????
    
    	system("pause");
    
    }

    Изучение бинарных деревьев. Компьютерная Академия "ШАГ" Киевский филиал

    KARTON, 10 Октября 2016

    Комментарии (59)