#include #include using namespace std; struct Punkt { double x; double y; }; // Uwaga: srednik na koncu! int main () { Punkt A = {3, 4}; // deklaracja 1 obiektu struktury Punkt + przypisanie bezposrednie wartosci polom cout << A.x << ' ' << A.y << endl; Punkt B = A; // przypisanie przez skopiowanie B.y = 1; cout << B.x << ' ' << B.y << endl; Punkt &C = A; // referencja na obiekt struktury C.x = -5; cout << C.x << ' ' << C.y << endl; cout << A.x << ' ' << A.y << endl; Punkt D = {3, -4}; // Tablica, ktorej elementami sa obiekty struktur :) valarray Trojkat (3); Trojkat[0] = A; // uwaga: indeksujemy od 0 Trojkat[1] = B; Trojkat[2] = D; for (int i=0; i<=2; i++) cout << "Trojkat[" << i << "] : x= " << Trojkat[i].x << " y= " << Trojkat[i].y << endl; Trojkat[0].x = 5; cout << Trojkat[0].x << endl; return 0; }