Difference between revisions of "Advanced-C++/C2/Inheritance/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
|||
Line 9: | Line 9: | ||
|- | |- | ||
| 00:06 | | 00:06 | ||
− | | In this tutorial we will learn | + | | In this tutorial, we will learn: |
|- | |- | ||
| 00:09 | | 00:09 | ||
− | | '''Inheritance''' | + | |* '''Inheritance''' |
|- | |- | ||
| 00:10 | | 00:10 | ||
− | |Types of '''inheritance''' | + | |* Types of '''inheritance'''. |
|- | |- | ||
Line 25: | Line 25: | ||
|- | |- | ||
| 00:16 | | 00:16 | ||
− | | To record this tutorial, I am using | + | | To record this tutorial, I am using: |
|- | |- | ||
| 00:19 | | 00:19 | ||
− | |'''Ubuntu OS '''version 11.10''' | + | |* '''Ubuntu OS '''version '''11.10''' |
|- | |- | ||
| 00:24 | | 00:24 | ||
− | |'''g++ compiler ''' | + | |* '''g++ compiler '''version '''4.6.1''' |
|- | |- | ||
| 00:28 | | 00:28 | ||
− | | Let us start with an | + | | Let us start with an introduction to Inheritance. |
|- | |- | ||
| 00:32 | | 00:32 | ||
− | |When one object acquires the property of another it is called as '''inheritance.''' | + | |When one '''object''' acquires the property of another, it is called as '''inheritance.''' |
|- | |- | ||
| 00:38 | | 00:38 | ||
− | |It is the process of reusing the existing class without modifying them. | + | |It is the process of reusing the existing '''class''' without modifying them. |
|- | |- | ||
| 00:44 | | 00:44 | ||
− | | Types of '''Inheritance''' | + | | Types of '''Inheritance'''- |
|- | |- | ||
| 00:45 | | 00:45 | ||
− | |'''Single level inheritance''' | + | |* '''Single level inheritance''' |
|- | |- | ||
| 00:48 | | 00:48 | ||
− | |'''Multiple level inheritance''' | + | |* '''Multiple level inheritance''' |
|- | |- | ||
| 00:50 | | 00:50 | ||
− | |'''Hierarchical Inheritance ''' | + | |* '''Hierarchical Inheritance ''' |
|- | |- | ||
| 00:52 | | 00:52 | ||
− | |'''Multilevel inheritance''' | + | |* '''Multilevel inheritance''' and |
|- | |- | ||
| 00:55 | | 00:55 | ||
− | |'''Hybrid Inheritance''' | + | |*'''Hybrid Inheritance'''. |
|- | |- | ||
|00:57 | |00:57 | ||
− | | First let us know about the '''base class''' and the '''derived class.''' | + | | First, let us know about the '''base class''' and the '''derived class.''' |
|- | |- | ||
| 01:02 | | 01:02 | ||
− | |The base class has its own properties and functionality. | + | |The '''base class''' has its own properties and functionality. |
|- | |- | ||
Line 101: | Line 101: | ||
|- | |- | ||
| 01:27 | | 01:27 | ||
− | | In '''single level inheritance''' only one base class and one derived class is needed. | + | | In '''single level inheritance''' only one '''base class''' and '''one derived''' class is needed. |
|- | |- | ||
| 01:34 | | 01:34 | ||
− | | '''Multiple inheritance''' | + | | '''Multiple inheritance'''- |
|- | |- | ||
| 01:37 | | 01:37 | ||
− | |In '''multiple inheritance''', '''derived class''' inherits from more than one base class. | + | |In '''multiple inheritance''', '''derived class''' inherits from more than one '''base class'''. |
|- | |- | ||
|01:44 | |01:44 | ||
− | | '''Hierarchical Inheritance''' | + | | '''Hierarchical Inheritance'''- |
|- | |- | ||
|01:47 | |01:47 | ||
− | | In '''Hierarchical Inheritance''' multiple derived classes | + | | In '''Hierarchical Inheritance''', multiple '''derived classes''' inherit from one '''base class.''' |
|- | |- | ||
| 01:55 | | 01:55 | ||
− | | '''Multilevel inheritance''' | + | | '''Multilevel inheritance'''- |
|- | |- | ||
| 01:57 | | 01:57 | ||
− | | In '''Multilevel inheritance''' the subclass acts as the '''base class''' for other classes. | + | | In '''Multilevel inheritance''', the '''subclass''' acts as the '''base class''' for other classes. |
|- | |- | ||
| 02:05 | | 02:05 | ||
− | | | + | | And '''Hybrid inheritance'''- |
|- | |- | ||
| 02:08 | | 02:08 | ||
− | | In '''hybrid inheritance''' more than one form of inheritance is combined. | + | | In '''hybrid inheritance''', more than one form of '''inheritance''' is combined. |
|- | |- | ||
Line 141: | Line 141: | ||
|- | |- | ||
| 02:18 | | 02:18 | ||
− | |I have already typed the code on the editor. | + | |I have already typed the code on the '''editor'''. |
|- | |- | ||
Line 149: | Line 149: | ||
|- | |- | ||
| 02:23 | | 02:23 | ||
− | |Note that our file name is '''exam_inherit.cpp''' | + | |Note that our file name is '''exam_inherit.cpp'''. |
|- | |- | ||
Line 157: | Line 157: | ||
|- | |- | ||
| 02:35 | | 02:35 | ||
− | | This is our header file as '''iostream''' | + | | This is our '''header file''' as '''iostream'''. |
|- | |- | ||
| 02:38 | | 02:38 | ||
− | | Here we are using the '''std namespace''' | + | | Here, we are using the '''std namespace'''. |
|- | |- | ||
| 02:42 | | 02:42 | ||
− | | Here we have class '''student.''' | + | | Here, we have class '''student.''' |
|- | |- | ||
| 02:44 | | 02:44 | ||
− | | Then we have an integer variable '''roll_no''' and '''character array name''', as private members of '''class student'''. | + | | Then we have an '''integer variable''' '''roll_no''' and '''character array name''', as '''private''' members of '''class student'''. |
|- | |- | ||
| 02:53 | | 02:53 | ||
− | | Function '''input '''and function''' display '''are the public functions of class student. | + | | Function '''input()''' and function''' display()''' are the '''public''' functions of '''class student'''. |
|- | |- | ||
| 02:59 | | 02:59 | ||
− | | Here we are using the '''input''' function to accept the roll no. and name of the student. | + | | Here we are using the '''input()''' function to accept the roll no. and name of the student. |
|- | |- | ||
| 03:06 | | 03:06 | ||
− | | Then we have the '''display''' function to display the roll_no and name. | + | | Then we have the '''display()''' function to display the roll_no and name. |
|- | |- | ||
| 03:11 | | 03:11 | ||
− | | Here we have another class as '''exam_inherit.''' | + | | Here we have another '''class''' as '''exam_inherit.''' |
|- | |- | ||
Line 193: | Line 193: | ||
|- | |- | ||
| 03:18 | | 03:18 | ||
− | |It inherits the function and data of class '''student.''' | + | |It inherits the function and data of '''class''' '''student.''' |
|- | |- | ||
| 03:23 | | 03:23 | ||
− | | Then we have declared ''' sub1, sub2, sub3 and total | + | | Then we have declared '''sub1, sub2, sub3''' and '''total''' |
|- | |- | ||
| 03:28 | | 03:28 | ||
− | | | + | |as '''private variables''' of '''class exam_inherit.''' |
|- | |- | ||
| 03:33 | | 03:33 | ||
− | | Here we have '''input_exam''' and '''display_exam''' as '''public functions.''' | + | | Here we have '''input_exam()''' and '''display_exam()''' as '''public functions.''' |
|- | |- | ||
| 03:41 | | 03:41 | ||
− | |Here we close the class '''exam_inherit.''' | + | |Here we close the '''class''' '''exam_inherit.''' |
|- | |- | ||
| 03:44 | | 03:44 | ||
− | | Now we are using '''input_exam '''function to accept the marks of three | + | | Now, we are using '''input_exam() '''function to accept the marks of three subjects. |
|- | |- | ||
| 03:52 | | 03:52 | ||
− | | Here, we are using '''display_exam''' function to calculate the total of three subjects. | + | | Here, we are using '''display_exam()''' function to calculate the total of three subjects. |
|- | |- | ||
| 03:59 | | 03:59 | ||
− | |Then we print a total. | + | |Then we '''print''' a total. |
|- | |- | ||
| 04:01 | | 04:01 | ||
− | | This is our '''main | + | | This is our '''main()''' function. |
|- | |- | ||
| 04:03 | | 04:03 | ||
− | | Here we create an object of class '''exam_inherit''' as '''ex''' | + | | Here we create an '''object''' of '''class''' '''exam_inherit''' as '''ex'''. |
|- | |- | ||
| 04:10 | | 04:10 | ||
− | | Then we call all the functions using the object '''ex''' | + | | Then we call all the functions using the object '''ex'''. |
|- | |- | ||
| 04:15 | | 04:15 | ||
− | | And this is our return statement. | + | | And this is our '''return''' statement. |
|- | |- | ||
| 04:18 | | 04:18 | ||
− | | Let us execute the program | + | | Let us execute the program. |
|- | |- | ||
| 04:20 | | 04:20 | ||
− | | Open the '''terminal''' | + | | Open the '''terminal''' '''window''' by pressing '''Ctrl, Alt''' and '''T '''keys simultaneously, on your keyboard. |
|- | |- | ||
| 04:30 | | 04:30 | ||
− | | To compile, type | + | | To compile, type: |
|- | |- | ||
| 04:31 | | 04:31 | ||
− | |'''g++ (space) exam_inherit.cpp (space)-o (space) exam''' | + | |'''g++ (space) exam_inherit.cpp (space)-o (space) exam'''. |
|- | |- | ||
| 04:41 | | 04:41 | ||
− | | Press Enter. | + | | Press '''Enter'''. |
|- | |- | ||
| 04:42 | | 04:42 | ||
− | |Type | + | |Type: |
|- | |- | ||
| 04:43 | | 04:43 | ||
− | |'''./ (dot slash)exam''' Press Enter. | + | |'''./ (dot slash) exam'''. Press '''Enter'''. |
|- | |- | ||
| 04:46 | | 04:46 | ||
− | | Here it is displayed as | + | | Here it is displayed as: |
|- | |- | ||
Line 277: | Line 277: | ||
|- | |- | ||
| 04:49 | | 04:49 | ||
− | | | + | |I will give as 1. |
|- | |- | ||
Line 285: | Line 285: | ||
|- | |- | ||
| 04:52 | | 04:52 | ||
− | |I will enter as '''Arya''' | + | |I will enter as '''Arya'''. |
|- | |- | ||
Line 293: | Line 293: | ||
|- | |- | ||
| 04:57 | | 04:57 | ||
− | |I will give as '''60''' | + | |I will give as '''60''', |
|- | |- | ||
Line 301: | Line 301: | ||
|- | |- | ||
| 05:02 | | 05:02 | ||
− | | | + | | and '''subjec 3''' as 80'''. |
|- | |- | ||
| 05:06 | | 05:06 | ||
− | | The output is displayed as | + | | The '''output''' is displayed as: |
|- | |- | ||
Line 313: | Line 313: | ||
|- | |- | ||
| 05:09 | | 05:09 | ||
− | |'''Name is: Arya''' and | + | |'''Name is: Arya''' and |
|- | |- | ||
| 05:11 | | 05:11 | ||
− | |'''Total is: 210''' | + | |'''Total is: 210'''. |
|- | |- | ||
| 05:13 | | 05:13 | ||
− | | Now we will see '''multilevel inheritance''' in the same example. | + | | Now, we will see '''multilevel inheritance''' in the same example. |
|- | |- | ||
Line 329: | Line 329: | ||
|- | |- | ||
| 05:20 | | 05:20 | ||
− | |Let's switch back to our editor. | + | |Let's switch back to our '''editor'''. |
|- | |- | ||
| 05:22 | | 05:22 | ||
− | |Note that our | + | |Note that our file name is '''multilevel.cpp'''. |
|- | |- | ||
| 05:28 | | 05:28 | ||
− | | Here we have declared the variable total. | + | | Here, we have declared the variable '''total'''. |
|- | |- | ||
| 05:32 | | 05:32 | ||
− | | | + | |as '''public variable''' of '''class''' '''exam_inherit.''' |
|- | |- | ||
| 05:38 | | 05:38 | ||
− | |This is because the private members are not accessed by the '''derived class.''' | + | |This is because the '''private''' members are not accessed by the '''derived class.''' |
|- | |- | ||
| 05:44 | | 05:44 | ||
− | | Here we have another class as '''grade.''' | + | | Here we have another '''class''' as '''grade.''' |
|- | |- | ||
Line 361: | Line 361: | ||
|- | |- | ||
| 05:56 | | 05:56 | ||
− | | | + | | and class '''exam_inherit''' is the '''base class''' for class '''grade'''. |
|- | |- | ||
| 06:02 | | 06:02 | ||
− | | All the | + | | All the '''function'''s and '''data''' of class '''exam_inherit''' will be inherited to class '''grade'''. |
|- | |- | ||
| 06:11 | | 06:11 | ||
− | | Here we have declared '''avg''' as '''private''' member of | + | | Here, we have declared '''avg''' as '''private''' member of '''class grade''' |
|- | |- | ||
| 06:17 | | 06:17 | ||
− | | | + | |and function '''average()''' as '''public''' function. |
|- | |- | ||
| 06:21 | | 06:21 | ||
− | |Then we close the class. | + | |Then we close the '''class'''. |
|- | |- | ||
| 06:23 | | 06:23 | ||
− | | Here we use the '''average''' function to calculate the average. | + | | Here we use the '''average()''' function to calculate the average. |
|- | |- | ||
Line 389: | Line 389: | ||
|- | |- | ||
| 06:30 | | 06:30 | ||
− | | Inside the main function we create an object of class grade as '''gd.''' | + | | Inside the main function, we create an '''object''' of '''class grade''' as '''gd.''' |
|- | |- | ||
Line 401: | Line 401: | ||
|- | |- | ||
| 06:42 | | 06:42 | ||
− | |'''input_exam''' | + | |'''input_exam()''' |
|- | |- | ||
| 06:44 | | 06:44 | ||
− | |'''display''' | + | |'''display()''' |
|- | |- | ||
| 06:45 | | 06:45 | ||
− | |'''display_exam''' | + | |'''display_exam()''' |
|- | |- | ||
| 06:46 | | 06:46 | ||
− | |and the '''average | + | |and the '''average()''' function. |
|- | |- | ||
Line 425: | Line 425: | ||
|- | |- | ||
| 06:56 | | 06:56 | ||
− | | | + | | and '''exam_inherit''' is the '''base class''' for class '''grade.''' |
|- | |- | ||
Line 433: | Line 433: | ||
|- | |- | ||
| 07:06 | | 07:06 | ||
− | | And class '''student''' is the base class for class '''exam_inherit.''' | + | | And class '''student''' is the '''base class''' for class '''exam_inherit.''' |
|- | |- | ||
| 07:12 | | 07:12 | ||
− | | Let us execute the program. | + | | Let us '''execute''' the program. |
|- | |- | ||
| 07:14 | | 07:14 | ||
− | | Come back to our terminal. | + | | Come back to our '''terminal'''. |
|- | |- | ||
| 07:17 | | 07:17 | ||
− | | To compile, type | + | | To compile, type: |
|- | |- | ||
Line 453: | Line 453: | ||
|- | |- | ||
| 07:26 | | 07:26 | ||
− | |Press '''Enter''' | + | |Press '''Enter'''. |
|- | |- | ||
Line 461: | Line 461: | ||
|- | |- | ||
| 07:30 | | 07:30 | ||
− | |Press '''Enter''' | + | |Press '''Enter'''. |
|- | |- | ||
Line 469: | Line 469: | ||
|- | |- | ||
| 07:34 | | 07:34 | ||
− | |I will enter as '''2''' | + | |I will enter as '''2'''. |
|- | |- | ||
Line 477: | Line 477: | ||
|- | |- | ||
| 07:38 | | 07:38 | ||
− | |I will enter as '''Pratham''' | + | |I will enter as '''Pratham'''. |
|- | |- | ||
Line 485: | Line 485: | ||
|- | |- | ||
| 07:43 | | 07:43 | ||
− | |I will give as '''65''' | + | |I will give as '''65''', |
|- | |- | ||
| 07:46 | | 07:46 | ||
− | |''' | + | |subject2 as '''67''' and |
|- | |- | ||
| 07:48 | | 07:48 | ||
− | |''' | + | |subject3 as '''82'''. |
|- | |- | ||
| 07:52 | | 07:52 | ||
− | | The output is displayed as: | + | | The '''output''' is displayed as: |
|- | |- | ||
Line 509: | Line 509: | ||
|- | |- | ||
| 07:57 | | 07:57 | ||
− | |'''Total is: 214 ''' and | + | |'''Total is: 214 ''' and |
|- | |- | ||
| 07:59 | | 07:59 | ||
− | |'''Average is: 71''' | + | |'''Average is: 71'''. |
|- | |- | ||
Line 521: | Line 521: | ||
|- | |- | ||
| 08:05 | | 08:05 | ||
− | |Let us move back to our slides. | + | |Let us move back to our '''slides'''. |
|- | |- | ||
| 08:07 | | 08:07 | ||
− | | Let us summarize | + | | Let us summarize. |
|- | |- | ||
| 08:08 | | 08:08 | ||
− | |In this tutorial, we learnt | + | |In this tutorial, we learnt: |
|- | |- | ||
| 08:10 | | 08:10 | ||
− | |'''Inheritance''' and | + | |* '''Inheritance''' and |
|- | |- | ||
| 08:11 | | 08:11 | ||
− | | Types of '''inheritance.''' | + | |* Types of '''inheritance.''' |
|- | |- | ||
| 08:14 | | 08:14 | ||
− | | As an assignment | + | | As an assignment- |
|- | |- | ||
| 08:15 | | 08:15 | ||
− | | | + | | write a program to create a '''class''' '''Shape'''. |
|- | |- | ||
| 08:18 | | 08:18 | ||
− | | Then | + | | Then create two '''function'''s of the '''class''' as '''Area''' and '''Perimeter'''. |
|- | |- | ||
Line 557: | Line 557: | ||
|- | |- | ||
| 08:31 | | 08:31 | ||
− | | Watch the video available at the link shown below | + | | Watch the video available at the link shown below. |
|- | |- | ||
| 08:34 | | 08:34 | ||
− | |It summarizes the Spoken Tutorial project | + | |It summarizes the Spoken Tutorial project. |
|- | |- | ||
| 08:37 | | 08:37 | ||
− | |If you do not have good bandwidth, you can download and watch it | + | |If you do not have good bandwidth, you can download and watch it. |
|- | |- | ||
| 08:42 | | 08:42 | ||
− | | The Spoken Tutorial Project Team | + | | The Spoken Tutorial Project Team: |
|- | |- | ||
| 08:44 | | 08:44 | ||
− | |Conducts workshops using spoken tutorials | + | |Conducts workshops using spoken tutorials. |
|- | |- | ||
| 08:47 | | 08:47 | ||
− | |Gives certificates to those who pass an online test | + | |Gives certificates to those who pass an online test. |
|- | |- | ||
| 08:51 | | 08:51 | ||
− | |For more details, please write to | + | |For more details, please write to: |
|- | |- | ||
Line 589: | Line 589: | ||
|- | |- | ||
| 08:58 | | 08:58 | ||
− | | Spoken Tutorial Project is a part of the Talk to a Teacher project | + | | Spoken Tutorial Project is a part of the "Talk to a Teacher" project. |
|- | |- | ||
Line 597: | Line 597: | ||
|- | |- | ||
| 09:09 | | 09:09 | ||
− | |More information on this | + | |More information on this mission is available at the link shown below. |
|- | |- | ||
| 09:13 | | 09:13 | ||
− | | This is Ashwini Patil from IIT Bombay signing off.Thank You for joining. | + | | This is Ashwini Patil from IIT Bombay, signing off. Thank You for joining. |
|} | |} |
Revision as of 22:49, 27 June 2015
Time | Narration |
00:01 | Welcome to the spoken tutorial on Inheritance in C++. |
00:06 | In this tutorial, we will learn: |
00:09 | * Inheritance |
00:10 | * Types of inheritance. |
00:12 | We will do this with the help of examples. |
00:16 | To record this tutorial, I am using: |
00:19 | * Ubuntu OS version 11.10 |
00:24 | * g++ compiler version 4.6.1 |
00:28 | Let us start with an introduction to Inheritance. |
00:32 | When one object acquires the property of another, it is called as inheritance. |
00:38 | It is the process of reusing the existing class without modifying them. |
00:44 | Types of Inheritance- |
00:45 | * Single level inheritance |
00:48 | * Multiple level inheritance |
00:50 | * Hierarchical Inheritance |
00:52 | * Multilevel inheritance and |
00:55 | *Hybrid Inheritance. |
00:57 | First, let us know about the base class and the derived class. |
01:02 | The base class has its own properties and functionality. |
01:06 | It is also called as parent class. |
01:09 | It has the common qualities that all the objects can inherit. |
01:14 | The derived class is the child class. |
01:18 | Derived class inherits the properties and functionality of the base class. |
01:23 | Let us see what is single level inheritance. |
01:27 | In single level inheritance only one base class and one derived class is needed. |
01:34 | Multiple inheritance- |
01:37 | In multiple inheritance, derived class inherits from more than one base class. |
01:44 | Hierarchical Inheritance- |
01:47 | In Hierarchical Inheritance, multiple derived classes inherit from one base class. |
01:55 | Multilevel inheritance- |
01:57 | In Multilevel inheritance, the subclass acts as the base class for other classes. |
02:05 | And Hybrid inheritance- |
02:08 | In hybrid inheritance, more than one form of inheritance is combined. |
02:14 | Now let us see an example on single level inheritance. |
02:18 | I have already typed the code on the editor. |
02:21 | I will explain it. |
02:23 | Note that our file name is exam_inherit.cpp. |
02:28 | The example involves to display the name, roll no and marks of the student. |
02:35 | This is our header file as iostream. |
02:38 | Here, we are using the std namespace. |
02:42 | Here, we have class student. |
02:44 | Then we have an integer variable roll_no and character array name, as private members of class student. |
02:53 | Function input() and function display() are the public functions of class student. |
02:59 | Here we are using the input() function to accept the roll no. and name of the student. |
03:06 | Then we have the display() function to display the roll_no and name. |
03:11 | Here we have another class as exam_inherit. |
03:16 | This is the derived class. |
03:18 | It inherits the function and data of class student. |
03:23 | Then we have declared sub1, sub2, sub3 and total |
03:28 | as private variables of class exam_inherit. |
03:33 | Here we have input_exam() and display_exam() as public functions. |
03:41 | Here we close the class exam_inherit. |
03:44 | Now, we are using input_exam() function to accept the marks of three subjects. |
03:52 | Here, we are using display_exam() function to calculate the total of three subjects. |
03:59 | Then we print a total. |
04:01 | This is our main() function. |
04:03 | Here we create an object of class exam_inherit as ex. |
04:10 | Then we call all the functions using the object ex. |
04:15 | And this is our return statement. |
04:18 | Let us execute the program. |
04:20 | Open the terminal window by pressing Ctrl, Alt and T keys simultaneously, on your keyboard. |
04:30 | To compile, type: |
04:31 | g++ (space) exam_inherit.cpp (space)-o (space) exam. |
04:41 | Press Enter. |
04:42 | Type: |
04:43 | ./ (dot slash) exam. Press Enter. |
04:46 | Here it is displayed as: |
04:47 | Enter Roll no.: |
04:49 | I will give as 1. |
04:51 | Enter Name: |
04:52 | I will enter as Arya. |
04:55 | Enter marks of subject1 |
04:57 | I will give as 60, |
05:00 | subject 2 as 70 |
05:02 | and subjec 3 as 80. |
05:06 | The output is displayed as: |
05:08 | Roll no is: 1 |
05:09 | Name is: Arya and |
05:11 | Total is: 210. |
05:13 | Now, we will see multilevel inheritance in the same example. |
05:18 | I have already typed the code. |
05:20 | Let's switch back to our editor. |
05:22 | Note that our file name is multilevel.cpp. |
05:28 | Here, we have declared the variable total. |
05:32 | as public variable of class exam_inherit. |
05:38 | This is because the private members are not accessed by the derived class. |
05:44 | Here we have another class as grade. |
05:49 | This inherits the class exam_inherit. |
05:53 | Class grade is the derived class |
05:56 | and class exam_inherit is the base class for class grade. |
06:02 | All the functions and data of class exam_inherit will be inherited to class grade. |
06:11 | Here, we have declared avg as private member of class grade |
06:17 | and function average() as public function. |
06:21 | Then we close the class. |
06:23 | Here we use the average() function to calculate the average. |
06:27 | Then we print the average. |
06:30 | Inside the main function, we create an object of class grade as gd. |
06:36 | Then we call all the functions using the object gd. |
06:40 | gd.input() |
06:42 | input_exam() |
06:44 | display() |
06:45 | display_exam() |
06:46 | and the average() function. |
06:49 | And this is our return statement. |
06:52 | Now you can see that class grade is the derived class. |
06:56 | and exam_inherit is the base class for class grade. |
07:01 | And here class exam_inherit is the derived class. |
07:06 | And class student is the base class for class exam_inherit. |
07:12 | Let us execute the program. |
07:14 | Come back to our terminal. |
07:17 | To compile, type: |
07:18 | g++ (space) multilevel.cpp (space) -o (space) mul |
07:26 | Press Enter. |
07:27 | Type ./mul |
07:30 | Press Enter. |
07:32 | Here we see, Enter Roll no.: |
07:34 | I will enter as 2. |
07:36 | Enter Name: |
07:38 | I will enter as Pratham. |
07:41 | Enter marks of subject1 |
07:43 | I will give as 65, |
07:46 | subject2 as 67 and |
07:48 | subject3 as 82. |
07:52 | The output is displayed as: |
07:54 | Roll no is: 2 |
07:56 | Name is: Pratham |
07:57 | Total is: 214 and |
07:59 | Average is: 71. |
08:01 | This brings us to the end of this tutorial. |
08:05 | Let us move back to our slides. |
08:07 | Let us summarize. |
08:08 | In this tutorial, we learnt: |
08:10 | * Inheritance and |
08:11 | * Types of inheritance. |
08:14 | As an assignment- |
08:15 | write a program to create a class Shape. |
08:18 | Then create two functions of the class as Area and Perimeter. |
08:23 | Then find the area and perimeter of various shapes like square, rectangle and circle. |
08:31 | Watch the video available at the link shown below. |
08:34 | It summarizes the Spoken Tutorial project. |
08:37 | If you do not have good bandwidth, you can download and watch it. |
08:42 | The Spoken Tutorial Project Team: |
08:44 | Conducts workshops using spoken tutorials. |
08:47 | Gives certificates to those who pass an online test. |
08:51 | For more details, please write to: |
08:53 | contact@spoken-tutorial.org |
08:58 | Spoken Tutorial Project is a part of the "Talk to a Teacher" project. |
09:02 | It is supported by the National Mission on Education through ICT, MHRD, Government of India. |
09:09 | More information on this mission is available at the link shown below. |
09:13 | This is Ashwini Patil from IIT Bombay, signing off. Thank You for joining. |