Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. // lasa.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <windows.h>
  7.  
  8. using namespace std;
  9.  
  10. int ID_global_clase = 0;
  11.  
  12. class ClasaTest {
  13. private:
  14. int id;
  15. public:
  16. ClasaTest() {
  17. id = ID_global_clase++;
  18. cout << "ClasaTest(): this=" << this << " idCLASA=" << id << endl;
  19. }
  20. ~ClasaTest() {
  21. cout << "~ClasaTest(): this=" << this << " idClasa=" << id << endl;
  22. }
  23. };
  24.  
  25. ClasaTest obiectGlobal; //obiect global class
  26.  
  27. void proceduraClasa(ClasaTest obiectCopiat, ClasaTest& obiectReferentiat, ClasaTest* obiectPointer) {
  28.  
  29. ClasaTest obiectLocal;
  30. static ClasaTest obiectStatic;
  31. }
  32.  
  33. int ID_global_structuri = 0;
  34.  
  35. struct StructuraTest {
  36. int id;
  37. };
  38.  
  39. void ConstStrucTest(StructuraTest* st) {
  40. st->id = ID_global_structuri++;
  41. cout << "StructuraTest(): this=" << st << " idStrc=" << st->id << endl;
  42. }
  43.  
  44. void DestructorStructTest(StructuraTest* st) {
  45. cout << "~StructuraTest(): this=" << st << " idStrc=" << st->id << endl;
  46. }
  47.  
  48. StructuraTest structuraGlobala;
  49. static StructuraTest* pointer_struc_Statica;
  50.  
  51. void proceduraStructura(StructuraTest strucCopiata, StructuraTest& structuraReferentiala, StructuraTest* structPointer) {
  52. ConstStrucTest(&strucCopiata);
  53.  
  54. StructuraTest structLocala;
  55. ConstStrucTest(&structLocala);
  56.  
  57. static int structuStaticaInstatiala = 0;
  58. static StructuraTest strucStatica;
  59. if (!structuStaticaInstatiala) {
  60. ++structuStaticaInstatiala;
  61. ConstStrucTest(&strucStatica);
  62. pointer_struc_Statica = &strucStatica;
  63. }
  64. DestructorStructTest(&structLocala);
  65. DestructorStructTest(&strucCopiata);
  66. }
  67.  
  68.  
  69. int main()
  70. {
  71. cout << endl;
  72. ClasaTest obiect_1;
  73. ClasaTest obiect_2;
  74. ClasaTest obiect_3;
  75. cout << endl;
  76. cout << "Apel proceduraClasa(Obiect, Obiect&, Obiect*):" << endl;
  77. proceduraClasa(obiect_1, obiect_2, &obiect_3);
  78.  
  79. cout << endl;
  80. StructuraTest structra_1;
  81. StructuraTest structra_2;
  82. StructuraTest structra_3;
  83. ConstStrucTest(&structra_1);
  84. ConstStrucTest(&structra_2);
  85. ConstStrucTest(&structra_3);
  86.  
  87. cout << "Apel proceduraStrucutra(Struct, Struct&, Struct*):" << endl;
  88. proceduraStructura(structra_1, structra_2, &structra_3);
  89.  
  90. cout << endl;
  91. DestructorStructTest(&structra_1);
  92. DestructorStructTest(&structra_2);
  93. DestructorStructTest(&structra_3);
  94.  
  95. system("pause");
  96.  
  97. /// INregistrare MOUSE
  98. HANDLE hIn;
  99. HANDLE hOut;
  100. COORD KeyWhere;
  101. COORD MouseWhere;
  102. COORD EndWhere;
  103. bool Continue = TRUE;
  104. int KeyEvents = 0;
  105. int MouseEvents = 0;
  106. INPUT_RECORD InRec;
  107. DWORD NumRead;
  108.  
  109. hIn = GetStdHandle(STD_INPUT_HANDLE);
  110. hOut = GetStdHandle(STD_OUTPUT_HANDLE);
  111.  
  112. cout << "Key Events : " << endl;
  113. cout << "Mouse Events : " << flush;
  114.  
  115. KeyWhere.X = 15;
  116. KeyWhere.Y = 0;
  117. MouseWhere.X = 15;
  118. MouseWhere.Y = 1;
  119. EndWhere.X = 0;
  120. EndWhere.Y = 3;
  121.  
  122. while (Continue)
  123. {
  124. ReadConsoleInput(hIn,
  125. &InRec,
  126. 1,
  127. &NumRead);
  128.  
  129. switch (InRec.EventType)
  130. {
  131. case KEY_EVENT:
  132. ++KeyEvents;
  133. SetConsoleCursorPosition(hOut,
  134. KeyWhere);
  135. cout << KeyEvents << flush;
  136. if (InRec.Event.KeyEvent.uChar.AsciiChar == 'x')
  137. {
  138. SetConsoleCursorPosition(hOut,
  139. EndWhere);
  140. cout << "Exiting..." << endl;
  141. Continue = FALSE;
  142. }
  143. break;
  144.  
  145. case MOUSE_EVENT:
  146. ++MouseEvents;
  147. SetConsoleCursorPosition(hOut,
  148. MouseWhere);
  149. cout << MouseEvents << flush;
  150. break;
  151. }
  152. }
  153.  
  154.  
  155. return 0;
  156.  
  157.  
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement