Skip to content

Commit fb71a92

Browse files
author
Sumit tripathi
committed
Implement code changes to enhance functionality and improve performance
1 parent e81e5e8 commit fb71a92

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

virtualFunction.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include<iostream>
2+
#include<cstring>
3+
using namespace std;
4+
class S7T{
5+
protected:
6+
string title[30];
7+
float rating;
8+
public:
9+
S7T(char *s, float r){
10+
strcpy(title, s);
11+
rating = r;
12+
}
13+
virtual void display(){}
14+
};
15+
class S7Tbrand : public S7T{
16+
float videoLength;
17+
public:
18+
S7Tbrand(char *s, float r, int vl) : S7T(s,r){
19+
videoLength = vl;
20+
}
21+
void display(){
22+
cout << "This is an very nice video with title " << title << endl;
23+
cout << "Rating: " << rating << " Out of 5 star" << endl;
24+
cout << "The length of this video is: " << videoLength << " minutes" << endl;
25+
}
26+
};
27+
class S7Tcomp : public S7T{
28+
int words;
29+
public:
30+
S7Tcomp(char *s, float r, int w) : S7T(s, r){
31+
words = w;
32+
}
33+
void display(){
34+
cout << "This is an very nice video with title " << title << endl;
35+
cout << "Rating: " << rating << " Out of 5 star" << endl;
36+
cout << "No. of words in this tutorial is: " << words << " words" << endl;
37+
}
38+
};
39+
int main(){
40+
string *title = new char[20];
41+
float rating, vlen;
42+
int words;
43+
title = "react tutorial by S7T";
44+
vlen = 5.70;
45+
rating 4.8;
46+
S7Tbrand rjsVideo(title, rating, vlen);
47+
return 0;
48+
}

virtualFunction.exe

43 KB
Binary file not shown.

0 commit comments

Comments
 (0)