Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. // Wykład_06.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.  
  12.     int tabT[3][2];
  13.     //int** ptr = tabT;
  14.  
  15.     int** tabD = new int*[3];
  16.     tabD[0] = new int[2];
  17.     tabD[1] = new int[2];
  18.     tabD[2] = new int[2];
  19.  
  20.     // ========================================
  21.  
  22.     int wrt = 10;
  23.  
  24.     typedef int LICZBA_CALKOWITA;
  25.  
  26.     LICZBA_CALKOWITA val1;
  27.     val1 = 10;
  28.  
  29.     cout << sizeof(int) << "\t" << sizeof(LICZBA_CALKOWITA) << endl;
  30.  
  31.     typedef int MY_TAB[3];
  32.  
  33.     MY_TAB testTab;
  34.     testTab[0] = 10;
  35.  
  36.     MY_TAB testTab2[5];
  37.  
  38.     LICZBA_CALKOWITA* ptr1 = &val1;
  39.  
  40.     MY_TAB* ptr2 = &testTab;
  41.  
  42.     // ==============================================
  43.  
  44.     union MyUnion {
  45.         int myInt;
  46.         char myChar;
  47.     };
  48.  
  49.     MyUnion myunion;
  50.     myunion.myInt = 500;
  51.  
  52.     cout << ">" <<myunion.myInt << "<" <<endl;
  53.     cout << ">" << (int)myunion.myChar << "<" << endl;
  54.  
  55.     struct MyStruct {
  56.         int myInt;
  57.         char myChar;
  58.  
  59.         bool equal(MyStruct* ptr) {
  60.             return ptr->myChar == myChar && ptr->myInt == myInt;
  61.         }
  62.     };
  63.  
  64.     MyStruct mystract;
  65.     mystract.myChar = 'a';
  66.     mystract.myInt = 10;
  67.  
  68.     MyStruct* ptr3 = new MyStruct();
  69.     ptr3->myChar = 'a';
  70.     ptr3->myInt = 10;
  71.  
  72.     MyStruct* ptr4 = new MyStruct();
  73.     ptr4->myChar = 'a';
  74.     ptr4->myInt = 10;
  75.  
  76.     cout << (mystract.equal(ptr4)) << endl;
  77.     cout << (ptr3->equal(ptr4)) << endl;
  78.  
  79.  
  80.     class MyClass {
  81.     public:
  82.         int myInt;
  83.         char myChar;
  84.     };
  85.  
  86.     MyClass myclass;
  87.  
  88.     cout << sizeof(MyStruct) << "\t" << sizeof(MyClass)<< endl;
  89.     //cout << mystract.myInt << "\t" << myclass.myInt << endl;
  90.  
  91.     return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement