Skip to content

Commit bf33469

Browse files
authored
Create 11 constructor.cpp
1 parent bafd06a commit bf33469

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Diff for: src/cpp/02 OOPS concept/11 constructor.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
class Employee{
5+
public:
6+
string Name;
7+
string Company;
8+
int Age;
9+
10+
void IntroduceYourself(){
11+
cout <<"Name - "<<Name<<endl;
12+
cout <<"Company - "<<Company<<endl;
13+
cout <<"Age - "<<Age<<endl;
14+
}
15+
Employee(string name, string company, int age){
16+
Name=name;
17+
Company=company;
18+
Age=age;
19+
}
20+
};
21+
22+
23+
int main ()
24+
{
25+
Employee employee1=Employee("Shivendra","No-company",23);
26+
employee1.IntroduceYourself();
27+
28+
Employee employee2=Employee("Nisha","Amazon",18);
29+
employee2.IntroduceYourself();
30+
31+
}

0 commit comments

Comments
 (0)