Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.95 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. //
  6. //void rekurencja(char* tab, int indeks)  //funkcja void bo nie zwraca niczego, tylko drukuje
  7. //{
  8. //    cout<< tab[indeks]<<endl; //wyswietlamy znak
  9. //    if(indeks>0) rekurencja(tab,indeks-1); //  funkkcja wywołuje samą siebie,, tylko z indeksem o jeden mniejszym
  10. //
  11. //
  12. //}
  13. //int main()
  14. //{
  15. //
  16. //    char tab[] = "ZNAKI"; //tworzymy tablice
  17. //    rekurencja(tab, 4); //wywolujemy funkcje rekurencja
  18. //}
  19. //referencje
  20. //
  21. //int main() {
  22. //    int k = 5;
  23. //    int &refk = k;
  24. //
  25. //    cout << "refk = " << refk << endl;
  26. //    cout << "   k = " << k    << endl;
  27. //
  28. //    k = 7;
  29. //
  30. //    cout << "refk = " << refk << endl;
  31. //    cout << "   k = " << k    << endl;
  32. //
  33. //    refk = 9;
  34. //
  35. //    cout << "refk = " << refk << endl;
  36. //    cout << "   k = " << k    << endl;
  37. //}
  38. //TABLICE
  39. //int main() {
  40. //    int tab[] = {1, 2, 3, 4, 5};
  41. //
  42. //    cout<<"Rozmiar: "<<sizeof(*tab)<<endl;
  43. //
  44. //    for (int i = 0; i < sizeof(*tab)+1; i++){
  45. //     cout<<tab[i]<<endl;
  46. //    }
  47. //
  48. //    int *wsk = &tab[sizeof(*tab)];
  49. //
  50. //    cout<<"Wskaznik na ostatni element tablicy: "<<*wsk<<endl;
  51. //
  52. //    while (*wsk != 0){
  53. //        cout<<*wsk<<endl;
  54. //        wsk--;
  55. //    }
  56. //}
  57. //klasy - konstruktory - destruktory
  58. //class Myclass {
  59. //public:
  60. //    int abc;
  61. //
  62. //    Myclass();
  63. //
  64. //    ~Myclass();
  65. //};
  66. //
  67. //Myclass::Myclass() {
  68. //    cout << "Wywolany konstruktor: " <<abc<< endl;
  69. //};
  70. //
  71. //Myclass::~Myclass() {
  72. //    cout << "Wykonany zostal destruktor" << endl;
  73. //}
  74. //
  75. //int main() {
  76. //    //Myclass myclass;
  77. //    int a;
  78. //    Myclass *myclass = new Myclass();
  79. //    //myclass = new Myclass(3);
  80. //    myclass->abc=8;
  81. //    cout<<myclass->abc<<endl;
  82. //    delete (myclass);
  83. //    cout<<a<<endl;
  84. //    cout<<myclass->abc<<endl;
  85. //}
  86. //Metoda
  87. //void wczytajTablice(int * tab,int size){
  88. //    cout<<"Rozmiar: "<< sizeof(*tab)<<endl;
  89. //    for(int i = 0; i< size ; i++){
  90. //        cout<<tab[i]<<endl;
  91. //    }
  92. //}
  93. //
  94. //int main(){
  95. //    int tab[] ={8,5,4,3,2,1,1,35,5,6};
  96. //    cout<<"Rozmiar: "<< sizeof(*tab)<<endl;
  97. //    wczytajTablice(tab,10);
  98. //}
  99. //class Test {
  100. //private:
  101. //    int rozmiar;
  102. //    string wielkosc;
  103. //public:
  104. //    Test(int rozmiar, string wielkosc) {
  105. //        this->rozmiar = rozmiar;
  106. //        this->wielkosc = wielkosc;
  107. //    };
  108. //    void pokaRozmiarWielkosc();
  109. //};
  110. //
  111. //void Test ::pokaRozmiarWielkosc() {
  112. //    cout<<"Pa jaki duzy: "<<rozmiar<<endl;
  113. //    cout<<"Pa jaki wielki: "<<wielkosc<<endl;
  114. //}
  115. //
  116. //int main() {
  117. //    Test * test1 = new Test(12, "big");
  118. //    Test * test2 = new Test(30 , "Very big");
  119. //
  120. //    test1->pokaRozmiarWielkosc();
  121. //    test2->pokaRozmiarWielkosc();
  122. //}
  123. //
  124. class destruktor {
  125.     public:
  126.         int abc;
  127.     ~destruktor();
  128. };
  129.  
  130. destruktor::~destruktor() {
  131.     cout<<"wykonano"<<endl;
  132. }
  133.  
  134. int main() {
  135.     destruktor *destruktor1 = new destruktor();
  136.     destruktor1->abc=1;
  137.     delete destruktor1;
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement