Taki kod:
#include <iostream>
using namespace std;
struct Test
{
int x;
};
int main()
{
Test t1{ 1 };
cout << t1.x << endl;
Test *t2 = new Test{ 1 };
cout << t2->x << endl;
Test t3[1]{ { 1 } };
cout << t3[0].x << endl;
Test *t4 = new Test[1]{ { 1 } };
cout << t4->x << endl;
return 0;
}
I w skrócie - dlaczego na wyjściu mam coś takiego?
1
1
1
-842150451