-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut3.cpp
34 lines (26 loc) · 785 Bytes
/
tut3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
using namespace std;
typedef struct employee // we make this for different type of data types in one place
{
int eID;
char favChar;
float salary;
} ekr; // any name you can give
union money // we make this for different type of data types in one place
{
int cash;
char upi;
};
int main(){
enum Meal{breakfast, lunch , dinner}; // 0, 1, 2
cout << lunch << endl;
union money account;
account.cash = 10;
account.upi = '1';
cout << account.cash << endl; // now I will get garbage value here for cash because union do memory management and changes only one datatype at a time (memory is shared)
cout << account.upi << endl;
ekr name12;
name12.eID = 13;
cout << name12.eID << endl;
return 0;
}