Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Test.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- struct BOD
- {
- int x;
- int y;
- };
- BOD *MyFunc1(BOD *val1)
- {
- return val1;
- };
- BOD &MyFunc2(BOD &val1)
- {
- return val1;
- };
- BOD MyFunc3(BOD &val1)
- {
- return val1;
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- // *** DYNAMICKÁ DEKLARACE *** //
- BOD *b1 = new BOD;
- b1->x = 5;
- BOD *bod1 = MyFunc1(b1); // Vypíše 5
- cout << bod1->x << endl;
- BOD &bod2 = MyFunc2(*b1); // Vypíše 5
- cout << bod2.x << endl;
- BOD bod3 = MyFunc3(*b1); // Vypíše 5
- cout << bod3.x << endl;
- // *** STATICKÁ DEKLARACE *** //
- BOD b2;
- b2.x = 6;
- BOD *bod4 = MyFunc1(&b2); // Vypíše 6
- cout << bod4->x << endl;
- BOD &bod5 = MyFunc2(b2); // Vypíše 6
- cout << bod5.x << endl;
- BOD bod6 = MyFunc3(b2); // Vypíše 6
- cout << bod6.x << endl;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment