-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut14.cpp
More file actions
51 lines (37 loc) · 1.02 KB
/
Copy pathtut14.cpp
File metadata and controls
51 lines (37 loc) · 1.02 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
using namespace std;
typedef struct employee //typedef is used to use a shortcut for 'struct employee'
{
int eId;
char favchar;
float salary;
}vr;
typedef union money
{
int rice;
char car;
float dollars;
}my;
int main(){
vr vighnesh;
vighnesh.eId = 876;
vighnesh.favchar = 'v';
vighnesh.salary = 100000000000;
// cout<<"The value is: "<<vighnesh.eId<<endl;
// cout<<"The value is: "<<vighnesh.favchar<<endl;
// cout<<"The value is: "<<vighnesh.salary<<endl;
my arjun;
arjun.rice = 5;
// arjun.car = 'B'; //In unions you can use any one value at a time. Otherwise, you'll get a garbage value!!
// arjun.dollars = 999999999;
cout<<arjun.rice<<endl;
enum meal{breakfast, lunch, snacks, dinner};
meal m = snacks;
cout<<m<<endl;
cout<<(m == 3)<<endl; //In this case it will either print 1 or 0 [Trure or False]
cout<<breakfast;
cout<<lunch;
cout<<snacks;
cout<<dinner;
return 0;
}