Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // lasa.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <windows.h>
- using namespace std;
- int ID_global_clase = 0;
- class ClasaTest {
- private:
- int id;
- public:
- ClasaTest() {
- id = ID_global_clase++;
- cout << "ClasaTest(): this=" << this << " idCLASA=" << id << endl;
- }
- ~ClasaTest() {
- cout << "~ClasaTest(): this=" << this << " idClasa=" << id << endl;
- }
- };
- ClasaTest obiectGlobal; //obiect global class
- void proceduraClasa(ClasaTest obiectCopiat, ClasaTest& obiectReferentiat, ClasaTest* obiectPointer) {
- ClasaTest obiectLocal;
- static ClasaTest obiectStatic;
- }
- int ID_global_structuri = 0;
- struct StructuraTest {
- int id;
- };
- void ConstStrucTest(StructuraTest* st) {
- st->id = ID_global_structuri++;
- cout << "StructuraTest(): this=" << st << " idStrc=" << st->id << endl;
- }
- void DestructorStructTest(StructuraTest* st) {
- cout << "~StructuraTest(): this=" << st << " idStrc=" << st->id << endl;
- }
- StructuraTest structuraGlobala;
- static StructuraTest* pointer_struc_Statica;
- void proceduraStructura(StructuraTest strucCopiata, StructuraTest& structuraReferentiala, StructuraTest* structPointer) {
- ConstStrucTest(&strucCopiata);
- StructuraTest structLocala;
- ConstStrucTest(&structLocala);
- static int structuStaticaInstatiala = 0;
- static StructuraTest strucStatica;
- if (!structuStaticaInstatiala) {
- ++structuStaticaInstatiala;
- ConstStrucTest(&strucStatica);
- pointer_struc_Statica = &strucStatica;
- }
- DestructorStructTest(&structLocala);
- DestructorStructTest(&strucCopiata);
- }
- int main()
- {
- cout << endl;
- ClasaTest obiect_1;
- ClasaTest obiect_2;
- ClasaTest obiect_3;
- cout << endl;
- cout << "Apel proceduraClasa(Obiect, Obiect&, Obiect*):" << endl;
- proceduraClasa(obiect_1, obiect_2, &obiect_3);
- cout << endl;
- StructuraTest structra_1;
- StructuraTest structra_2;
- StructuraTest structra_3;
- ConstStrucTest(&structra_1);
- ConstStrucTest(&structra_2);
- ConstStrucTest(&structra_3);
- cout << "Apel proceduraStrucutra(Struct, Struct&, Struct*):" << endl;
- proceduraStructura(structra_1, structra_2, &structra_3);
- cout << endl;
- DestructorStructTest(&structra_1);
- DestructorStructTest(&structra_2);
- DestructorStructTest(&structra_3);
- system("pause");
- /// INregistrare MOUSE
- HANDLE hIn;
- HANDLE hOut;
- COORD KeyWhere;
- COORD MouseWhere;
- COORD EndWhere;
- bool Continue = TRUE;
- int KeyEvents = 0;
- int MouseEvents = 0;
- INPUT_RECORD InRec;
- DWORD NumRead;
- hIn = GetStdHandle(STD_INPUT_HANDLE);
- hOut = GetStdHandle(STD_OUTPUT_HANDLE);
- cout << "Key Events : " << endl;
- cout << "Mouse Events : " << flush;
- KeyWhere.X = 15;
- KeyWhere.Y = 0;
- MouseWhere.X = 15;
- MouseWhere.Y = 1;
- EndWhere.X = 0;
- EndWhere.Y = 3;
- while (Continue)
- {
- ReadConsoleInput(hIn,
- &InRec,
- 1,
- &NumRead);
- switch (InRec.EventType)
- {
- case KEY_EVENT:
- ++KeyEvents;
- SetConsoleCursorPosition(hOut,
- KeyWhere);
- cout << KeyEvents << flush;
- if (InRec.Event.KeyEvent.uChar.AsciiChar == 'x')
- {
- SetConsoleCursorPosition(hOut,
- EndWhere);
- cout << "Exiting..." << endl;
- Continue = FALSE;
- }
- break;
- case MOUSE_EVENT:
- ++MouseEvents;
- SetConsoleCursorPosition(hOut,
- MouseWhere);
- cout << MouseEvents << flush;
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement