Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <string>
- using namespace std;
- struct Container
- {
- string Name;
- int X;
- int Y;
- int Z;
- };
- int main()
- {
- Container container = { "Sam", 30, 20, 50 };
- // Create pointer to 'container'
- Container* PtrToCont = &container;
- // Dereference PtrToCon --- should print 'Sam' in both instances
- // (Parentheses required to dereference 'PtrToCont' first
- // before using dot operator)
- cout << (*PtrToCont).Name << endl;
- // OR, use this preferred syntax:
- cout << PtrToCont->Name << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement