-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut14.cpp
More file actions
38 lines (35 loc) · 772 Bytes
/
Copy pathtut14.cpp
File metadata and controls
38 lines (35 loc) · 772 Bytes
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
35
36
37
38
#include<iostream>
using namespace std;
typedef struct employee
{
int eId;
char favChar;
float salary;
}ep;
union money
{
int rice;
char car;
float pounds;
};/*union allow only one of the many inputs*/
int main(){
enum meal{ breakfast,lunch,dinner};
meal m2=lunch;
cout<<(m2==2);
cout<<breakfast;
cout<<lunch;
cout<<dinner;
ep harry;
harry.eId=1;
harry.favChar='c';
harry.salary=1200000;
cout<<"the value is "<<harry.eId<<endl;
cout<<"the value is "<<harry.favChar<<endl;
cout<<"the value is "<<harry.salary<<endl;
union money m1;
m1.rice=34;
m1.car='c';
cout<<m1.rice<<endl;/*this returns garbage value as you have changed m1 to car */
cout<<m1.car<<endl;
return 0;
}