-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontainment.cpp
More file actions
83 lines (72 loc) · 1.35 KB
/
containment.cpp
File metadata and controls
83 lines (72 loc) · 1.35 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//Program that shows the concept of containment
#include<iostream>
#include<cstring>
using namespace std;
class cDate
{
char day[10];
int month;
int year;
public:
cDate(char[],int,int);
~cDate();
};
cDate::cDate(char day[10],int month,int year)
{
strcpy(this->day,day);
this->month=month;
this->year=year;
cout<<"cDate Constructor";
}
cDate::~cDate()
{
cout<<"cDate Destructor";
}
class cString
{
int len;
char *str;
public:
cString(int,char *);
~cString();
};
cString::cString(int len,char buff[50])
{
this->len=len;
str=new char[len+1];
strcpy(str,buff);
cout<<"String constructor called";
}
cString::~cString()
{
delete[] str;
cout<<"string destructor";
}
class cEmployee
{
int id;
cString Ename;
cDate doj;
public:
cEmployee(int,int,char *,char[],int,int);
~cEmployee();
void seteverything();
};
cEmployee::cEmployee(int id,int len,char* name,char day[10],int mon,int yr):Ename(len,name),doj(day,mon,yr)
{
cout<<"employee constructor called";
}
cEmployee::~cEmployee()
{
cout<<"employee destructor";
}
void cEmployee::seteverything()
{
cout<<"enter id";
cout<<id;
}
int main()
{
cEmployee ramesh(1,10,"ramesh","monday",3,2016);
ramesh.seteverything();
}