Advertisement
dllbridge

Untitled

Sep 28th, 2024
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.32 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5.  
  6. ////////////////////////////////////////
  7. struct T
  8. {
  9.    
  10.    static int nCounter;
  11.        
  12.    int nSec;    
  13.    int nMin;
  14.    char szName[77];
  15.  
  16.    void get(int n);
  17.    
  18.    void monitor();
  19.    
  20.    T()
  21.    {
  22.        
  23.         nCounter ++;
  24.         nSec = 20;
  25.         nMin = 10;    
  26.         strcpy(szName, "noname");
  27.    }
  28.  
  29. };
  30.  
  31. int T::nCounter = 0;
  32.  
  33. void monitor(T *p);
  34.  
  35.  
  36. /////////////////////////////////////////////////////////////////////
  37. int main()                                                         //
  38. {
  39.  
  40.     T t_1, t_2;
  41.    
  42.     t_1.get(712);
  43.  
  44.     t_2.monitor();
  45.  
  46.     printf("&t_2 = %d\n", &t_2);
  47.    
  48.     printf("t_1.nCounter = %d\n", t_1.nCounter);
  49.     printf("t_2.nCounter = %d\n", t_2.nCounter);
  50.     printf("sizeof(t_1) = %d\n", sizeof(t_1));
  51.     printf("address of t_2.nSec = %d\n", &t_2.nSec);          
  52. }
  53.  
  54.  
  55. //////////////////////////////////////////////////////////////////////
  56. void T::monitor()
  57. {
  58.      printf("Minuts  = %d\n", this -> nMin);
  59.      printf("Seconds = %d\n", this -> nSec);    
  60.      printf("szName  = %s\n", this -> szName);
  61.      
  62.      printf("this = %d\n", this);  
  63. }
  64.  
  65.  
  66. ////////////////////////////////////////////
  67. void T::get(int n)
  68. {
  69.        
  70.         nMin = n / 60;      
  71.         nSec = n % 60;
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement