-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut57.cpp
executable file
·55 lines (47 loc) · 1.33 KB
/
tut57.cpp
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
#include <iostream>
#include <string>
class Account {
public:
std::string username;
int followers;
Account(std::string str, int flwrs) {
username = str;
followers = flwrs;
}
virtual int display() {}
};
class Post: public Account {
int likes;
public:
Post(std::string str, int flwrs, int lks) : Account(str, flwrs) {
likes = lks;
}
int display() {
std::cout << "Username: " << username << std::endl;
std::cout << "Followers: " << followers << std::endl;
std::cout << "Post Likes: " << likes << std::endl;
return 0;
}
};
class Reel: public Account {
int likes;
public:
Reel(std::string str, int flwrs, int lks) : Account(str, flwrs) {
likes = lks;
}
int display() {
std::cout << "Username: " << username << std::endl;
std::cout << "Followers: " << followers << std::endl;
std::cout << "Reel Likes: " << likes << std::endl;
return 0;
}
};
int main() {
Post ob1("_kanav_6868", 100, 68);
Reel ob2("_kanav_6868", 100, 68);
Account *ptr1 = &ob1;
Account *ptr2 = &ob2;
ptr1->display();
ptr2->display();
return 0;
}