-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLAB8.cpp
More file actions
41 lines (38 loc) · 754 Bytes
/
Copy pathLAB8.cpp
File metadata and controls
41 lines (38 loc) · 754 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
39
40
41
/*Develop a C++ program using Constructor in Derived classes
to initialize alpha, beta and gamma and display corresponding values.*/
#include <iostream>
using namespace std;
class Base
{
int alpha;
char beta;
float gamma;
public:
Base(int a,char b,float g)
{
alpha=a;
beta=b;
gamma=g;
cout<<"In base class constructor\n";
}
void display()
{
cout<<"alpha "<<alpha<<endl;
cout<<"beta "<<beta<<endl;
cout<<"gamma "<<gamma<<endl;
}
};
class Derived : public Base
{
public:
Derived(int a,char b,float g) : Base(a,b,g)
{
cout<<"In derived class constructor\n";
}
};
int main()
{
Derived d(1,'2',3.2);
d.display();
return 0;
}