-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractClass.cpp
More file actions
46 lines (42 loc) · 820 Bytes
/
Copy pathAbstractClass.cpp
File metadata and controls
46 lines (42 loc) · 820 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
42
43
44
45
46
//pure virtual function is called Abstract class
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
//super class
class person
{
private:
int age;
public:
virtual void setAge(int a)
{
age = a;
}
virtual void showAge()
{cout<<"Age is "<<age<<endl;}
//do nothing function with virtual keyword containing class called Abstract class
//we cannot create object of abstract class
virtual void fun1() =0;
};
//inherited class
class student:public person
{
private:
char name[20];
public:
void fun1() //function is overriding
{
cout<<"This is studend . ";
}
};
int main()
{
system("cls");
student s1;
s1.setAge(20);
s1.showAge();
s1.fun1();
system("pause");
return 0;
}