// struct initialization
#include <iostream>
#include <string>
using namespace std;
struct MyStruct
{
int x;
double y;
string z;
};
int main()
{
MyStruct obj1;
obj1.x = 4;
obj1.y = 123.456;
obj1.z = "Oliver";
cout << obj1.x << ' ' << obj1.y << ' ' << obj1.z << endl;
MyStruct* pMS;
// pMS -> x = 5; Run-time error
pMS = &obj1;
pMS -> x = 5;
cout << obj1.x << ' ' << obj1.y << ' ' << obj1.z << endl;
pMS = new MyStruct;
pMS->x = 2;
pMS->y = 2.5;
pMS->z = "Owen";
cout << pMS->x << ' ' << pMS->y << ' ' << pMS->z << endl;
MyStruct obj2 = {8,.5,"Julia"}; // this doesn't work with a class
cout << obj2.x << ' ' << obj2.y << ' ' << obj2.z << endl;
}