Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- struct Test
- {
- int id;
- bool flag;
- };
- struct Point
- {
- int x;
- int y;
- };
- //printPoint(pOne);
- void printPoint(const Point& pnt)
- {
- std::cout << "(" << pnt.x << "," << pnt.y << ")" << '\n';
- }
- void printPoint(const Point& pntOne, const Point& pntTwo)
- {
- std::cout << "(" << pntOne.x << "," << pntOne.y << ")" << '\t';
- std::cout << "(" << pntTwo.x << "," << pntTwo.y << ")" << '\n';
- }
- Point generatePoint()
- {
- Point pnt;
- pnt.x = rand() % 100;
- pnt.y = rand() % 100;
- return pnt;
- }
- int main()
- {
- int a{ 3 };
- int b{ a };
- Point pOne{ 1,2}; // pOne.x = 1 pOne.y = 2
- Point pTwo{ pOne }; // pTwo.x = 1 pTwo.y = 2
- pTwo.x = 555;
- Point* ptrPoint{nullptr};
- ptrPoint = new Point[2]{ {11,22},{33,44} };
- Point& refPoint{ pOne };
- refPoint.x = 333;
- //std::cout << "pOne.x = " << pOne.x << " pOne.y = " << pOne.y << '\n';
- printPoint(pOne);
- // ??? :)
- printPoint(pOne);
- Point pntTree{ generatePoint() };
- printPoint(pntTree);
- printPoint(pOne, pntTree);
- std::cout << "ptrPoint->x = " << ptrPoint[1].x << " ptrPoint->y = " << ptrPoint[1].y << '\n';
- /*pOne.x = 10;
- pOne.y = 10;*/
- delete[] ptrPoint;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement