Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Inheritance & Polymorphism in OOPs
Play lesson

System Design Full Course - Inheritance & Polymorphism in OOPs

5.0 (4)
27 learners

What you'll learn

This course includes

  • 34.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

System Design Full Course Inheritance & Polymorphism in OOPs

Inheritance & Polymorphism in OOPs Transcript and Lesson Notes

حنجی تو کریں start so welcome back to our LLD playlist last video if you remember we had seen two objects oriented programming and two pillars which were abstraction and encapsulation aside from this two pillars last video which are inheritance and polymorphism which we will see in today's video same way we will do

Quick Summary

حنجی تو کریں start so welcome back to our LLD playlist last video if you remember we had seen two objects oriented programming and two pillars which were abstraction and encapsulation aside from this two pillars last video which are inheritance and polymorphism which we will see in today's video same way we will do

Key Takeaways

  • Review the core idea: حنجی تو کریں start so welcome back to our LLD playlist last video if you remember we had seen two objects oriented programming and two pillars which were abstraction and encapsulation aside
  • Understand how System Design fits into Inheritance & Polymorphism in OOPs.
  • Understand how Low Level Design fits into Inheritance & Polymorphism in OOPs.
  • Understand how High level Design fits into Inheritance & Polymorphism in OOPs.
  • Understand how System Design for Beginner fits into Inheritance & Polymorphism in OOPs.

Key Concepts

Full Transcript

حنجی تو کریں start so welcome back to our LLD playlist last video if you remember we had seen two objects oriented programming and two pillars which were abstraction and encapsulation aside from this two pillars last video which are inheritance and polymorphism which we will see in today's video same way we will do it same concept we will try to understand the same example and we will carry out the same example which was our car so you will not be able to understand it so let's jump directly screenpads so let's start with inheritance so what is inheritance look we have observed that in real life objects related to each other meaning there is a relationship in them and we call that relationship parent-child relationship for example I say in real life there is an object A and an object B according to this theory this is B object this is related to A or I can say B object child and A object parent and we get to see this in real life and because the object acts in real life we have to represent it in programming and in programming terms we use inheritance to represent it so let's go let's understand the example how we see in real life we see parent-child relationship so again take our car example let's understand this let's say we have a car now see the car is very generic car can be a car so let's say car is a car we have two different objects let's say car is a car manual car and car is a car electric car car is a car manual car is a car which has a gear system it runs on a petrol or diesel and car is an electric car which runs on a job-visual electricity and car is automatic car is not needed in this car so car is a car in real life car is also existing car is also existing but we can observe that car is a car and electric car both cars are right so we can say car and in these two cars in manual and electric car parent-child relationship which has a car which has a car and these two cars are child so because this is a characteristic we get to see in real life so again we should represent it programmatically because the object is also showing the feature as we did in abstraction encapsulation so let's move on to the next example and let's talk about what is the feature in a car okay so now I will give this parent-child to me let's see what is the characteristic feature in a car so let's start first of all let's talk about the characteristics okay as we saw in other examples we will do the same every car has a brand every car has a model okay and again we can see the same property that is engine on right because the engine can be off because we have seen in every car right what else can we see in this car we can see the current speed right so this is the property which every car will show right and we have some behavior which can show every car for example if every car will start then the function of the start engine will be LR the stop engine will also be the function we saw in the last video what else can we see obviously every car can be excellent and the brake can be broken on every car so I am saying this is the feature which you will see in every car right so this feature is specific to every car right not we will see in every car we will see in every car but which is our manual car obviously all the features but in this there will be some special feature which you will see in our normal car in another car okay now what is the special feature let's see see in the manual car we have a gear system right so we have a current gear and a character right which we have to keep what is the gear and if we see in the behavior the same we have a shift gear behavior here this is not necessary in every car as we will see in electric car the system of shift gear right let's go now let's see in electric car what will happen in electric car in electric car that it will have battery right so let's do battery percentage so this will happen in other in which the battery percentage is right and we have a behavior which we can say charge battery which we can charge now this is also a specific electric car because this is the battery charge feature this is not in the manual car and the same this is the shift gear feature here this is not in the electric car so basically we want to say that the car the parent object the car is the parent object there are some characters and some behaviors which we will see in every car whether it is a manual car or electric car but according to this this is our child like manual car electric car they have some specific function which you will only see in them they will not see in every car so they are specific to their own object like the manual car's specific feature which will have a gear shifting feature electric car's special feature which will have a charge battery feature right? understood so this whole story is real world okay? now I will show you how I represent this object oriented programming so as we were first we do the same thing let's see what we do? first of all let's make a class car okay?

we made a car a class car and now all the characters and basically all the characters which are behavior we represent this car again like we have modeled brand right? etc. and then we also have start engine stop engine etc. all these things we will define this class after that our two child classes so one of us becomes class what is our name?

we have a manual car we write manual car inherits car we write this operator you may know okay? so we write it manual car inherits car by this operator okay? now we understand we have written here public this is very important okay? if we write private if we write private what would happen?

we have a protected access modifier which we will see in inheritance so we will see so if we write this what would happen? so we will see when we will see the code then you will understand better but now you can say this is the syntax which we write to inherit the car to inherit the class so we made a class manual car and manual car because the child class is the car inherits from public car so this operator put this operator simple now what we did? because we made this inheritance relationship in this car basically in this car's body only those characters and those behavior will define which is for this manual car which was shift gear right? shift gear we had VVR and what was in the current gear?

so this is our characteristic that the current gear is 0 and the shift gear function so we will define in manual car but this manual car can call all the methods and all VVR can access which was in this car how? this is the property of the property of inheritance right? now basically we have to do this again all the characters and all the behavior in manual car we have to define our work we have done just the manual car and defined which is specific and what we will do we will do our second car electric car we will switch electric car we will do the same same class electric car we will write public car and what we will do in that we will write the same feature which is specific to electric car which was the feature which is the electric car which was our charge battery this was the behavior and the character of this car which is the battery percentage right? so again this electric car can call all the methods which are specific which are basically the car which are represented so that start engine, stop engine, accelerate, brake can call all the same manual car what are the methods called all the behavior and all the characters can access simple and we don't need to define it from that time so this is the whole story of inheritance very simple inheritance like out of all the four inheritance is the most common and easily understood like other things can be confusing but inheritance is never confusing let's discuss a class we wrote class manual car which is inheriting from public and I asked you if in public place I write private or protected what will happen?

let's try to understand this and then we will jump directly see as we read we have sorry as we read we have three access modifier okay? what was it? it was a public private and last we were protected we read about public and private if we declare a behavior to a public character then he can access from the outside and if we declare private then only the methods or the characters in the class can access variable now a class was saved protected what if we declare a method to a variable then what happens? whenever we call a variable protected then they say no one can access but they can access the characters of the child so what does it mean?

if we write a method or a variable then it means it can't access just this condition if we make a child class and the methods or variables can access so this was protected and if you look at practical then it is very less protected generally we use private but still because we understood now we will go back to our question generally we use class manual car inherits from public car if i write public i mean i mean the main class and the variables and the methods when i will inherit the person who is protected and private then we cannot access basically if we look at public car if we look at it the public car which we have has three things brand model and current speed we will get three things so our three things we were saying that the brand is the model and current speed if we declared private we cannot access it because we cannot access it because we have private property and we cannot access it if we can get private and public then we can access manual car and we can access it but if i would have protected then what would happen then we will change the story if we would have protected then we can only access manual car and the methods we cannot access it so we have asked the question if i am writing public then i am saying let's do this if i is our car and this is our manual car okay if i am inheriting i am inheriting three conditions if i am inheriting our car and this is our public and this is our private and this is our protected so i am inheriting this is our manual car which inherits the public which inherits the public and this is our private and this is our protected so i would have protected if i am writing public then what would happen then nothing would happen and this is our public and this is our public okay if i am inheriting then what happened then what happened the public member was in manual car and this is our manual car but this is our manual car and this is our manual car and this is our factory and this is our factory and this is our نے بھی پروטیکٹڑ ہوتے وہ بھی پریوڑ بن جاتے اور again, private wale tume excessi ni garpata اور last, اگر میں اسے پروٹیکٹڑ لی Exodus کرتا تو اب تو آپ understood P public wale pprotected بن جاتے Protected wale protected ی رہے تھے اور private wale máXessi ni garpata تو بس پوری کہنی ہوتے ہیں تو میں جس بھی طریقے سے سکس کرتا ہوں بسیگلیا گا میں اس کو public ke jaga private liktah hoon ya protected liktah hoon تو ہوتا کچھ نہیں ہے جت نے بھی اس کے کار کے Metheards پبولی کیا پرٹیکٹڑ وہ وہی بن جاتے ہیں جس کے thrumas کو ایکسس کر رہوں اور پریوٹ میں کبھی ایکسسی نہیں کر پا تھا لیکن یہ سب تھیوریٹی کا لہیں پرکٹیکٹی کے لیگر میں تو میں وطاום پوری لڑی میں یا پورے سیسٹم دیزائیں میں یا ریالیسی ناریوں میں بھی ہم موست of the time ہمیں ایشا اگر 99% of the time پبولی کلی اینہریٹھی کرتے ہیں ہم کبھی بھی اس کو پرٹیکٹڑی لیہ پریوٹ لی ناریٹھی کرتے کیا وہ اگر آپ کہہ سکتے ہو کہ وہ اینہریٹھنز کی پرنسیپل کوئی بریک کر دیتے ہیں اینہریٹھنز کا پرنسیپل کیا کہتا ہمیں اینہریٹھنز کا پرنسیپل یہ کہتا ہے کہ ہم چاہل کلاس میں وہ سارے فیچر کو ایکسس کر پائے جو پیرینٹلاس میں اور جو چاہل کلی ایکسس کرتے ہیں جو ایکسسس پیسے فکٹو چاہل کلاسے ہیں جو امریکنے میں بھی کار میں دیکھا جنگرری وہ رستیکٹ کرتا ہمیں جو امریکنے سے پریوٹیٹڑی لیے پریوٹیٹڑی ایکسس کرتے ہیں جنگرری میں نہیں کرتے ہیں بہت ریر کس ہوگا کوئی ایک کا دو کا ایکسسسسس میں میں سا کریں گے تو یہ سارہ تھیری تھی اینہریٹھنز کی چاہلو جمپ کرتے ہیں کوڑ کی طرف اور کوڑ دیکھتے ہیں تو یہ دیکھو سپ سے پہلے ہماری قلاسیز دیکھلے جس ہم نے بات کیا ہمارے پاسے کار تھی اور دو منوال کار ایلیکٹری کار اس کو پبلكلی اینہریک کر ریتی تھی کہ اینہریکٹس سے کار اینہریکٹس سے کار اب ایک ایک کار کے ایک حولتے ہیں سپ کو کار کو حولتے ہیں دیکھو سپ سے پہلے میں نے کیا کہ میں نے کو پرٹیکٹی دیکھلے کر دیا یہ سارہ کیریکٹرس کو بیسکلی سارہ ایریبالس کو جو کار کندرتے برانڈ موڑل اب یہ specif genric ہر کاری میں یہ ایک ایک کرکٹرس تو ہوں گے Right اسلے میں نے اس کو کار میں دال ہے میں اس کو منوال کار اور ایلیکٹری کار میں نہیں دالوں گا کیو کی وہ یہ منوال کار ایلیکٹری کار یہاں سے دیکھلی ایکسکتے ہیں اب اسے میں نے protect it ڈکلیر کیا جس میں نے discuss کیا اب اسے class کے بہار کو ایکسکتے نہیں کر سکتے لیکن منوال کار اور ایلیکٹری کاری سکسکتے ہیں اب ہم اپنے بھیویر دیکھلے دیکھلے جو ہمارے پبل تو مرا کنسٹٹٹر ہے پھر یہ کاما Method ہے جو ہر گاہدی میں ہوتا ہوتا ہوتا ہوتا ہوتا ہوتا ہوتا ہر گاہدی میں بولا start-in-john ہوتا stop-in-john ہوتا excel-rate ہوتا ہوتا ہوتا ہوتا ہوتا ہوتا اب یہ Method Same جو میں Ep Straction واقعی Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

Dr. Dr. Dr. Dr.

کر�ٹھ سپیڑ کو پر اس کے ساتھی کر�ٹ گیر کو بھی ھوز کر سکتے ہیں کیوں کی اس پیسپیک فیچھر ہے اس منوالگار کا تو سے میں اس کا کسٹڑٹڑ نہیا اور ایک فنشم نہ دیہ Shift gear again this is specialized method for manual car اب اس گاڈی کے اندر صرف میر کو دیکھو ایکی فنشہ لکھنا پڑا پر still یہ گاڈی اور منوالگار یہ سارے میتھڑس کو start engine, stop engine Excel raid اور break ھن سپ کو ھوز کر سکتے ہیں تو میرا کتنا سارا کوڑ لکھنا بچ گیا رائیڈ تو سے inheritance میرا کتنا کاما سان کر دیتا ہے اب again jump کرتے ہیں electric car کو electric car میں same میں ایک اور نیا فیچھر لگیا battery level جیسے بیٹری پر سندج کلو battery level کلو اس کو بہنے private بنایا یہ specific ہے car کے لیے اور again specialize method لکھ دیا چارج battery OK اور یہ again specialize ہے car electric car کے لیے اب ہم اپنے اپنے main function میں دیکھتے ہم نے کیا ہم نے ایک manual car بنائیں اور ہم نے electric car بنائیں Light یہاں میں manual car Suzuki wagon and Radhi electric car میں touch la rut لیے تو ام دیکھو اس میں start engine call کر سکتے ہیں اس میں بھی start engine اس میں shift gear اس میں بھی sorry اس میں shift gear call کر سکتے ہیں لیکن یہ specific ہے manual car میں ہم electric car میں shift gear کا function call in کر سکتے ہیں کیا ہم نے اس میں بنائیں ہونہ این ہی چیے right accelerate 2 موسکتا break 2 موسکتا stop engine 2 موسکتا لیکن جیسے اس میں charge battery specific ہے yeah so you can see the output same engine started shift gear 1 کیا ہمیں shift ہو سکتے ہیں اور اس کے لی battery full charge call ہوگا کیا ہم نے use کیا charge battery جو کی just Tesla model S Suzuki wagon Arbham charge battery call نہیں کر سکتے ہیں کیا ہم electric car h نہیں ہے so this is all about inheritance چاہلو اب واپا سے jump کرتے ہیں اب نے last topic کے در of joki ہے polymorphism اب ہمنا کیا کرنے چاہرے ہیں اب نے real world سے ایک آخری اٹھانے جانے جو کیا polymorphism جو object show کرتے ہیں اور اس کو ایک برگر ہم نے προجرامیگوں ممک کر دیا نہ تو ہمارے سارا کام ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم stro ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم ختم خativ ختم ختم ختم ختم ختم ختم تو آپ کو پتے ہیں, مجھے دکھ کردھر بھی رہن ہوگا آجائے گپنے آپ, ہیمان کندھر بھی رہن آجائے گھا, ٹیگر کندھر بھی رہن آجائے گھا, کیوں اس کو انہیرٹ کر رہے ہیں. میں یہ کہہ رہوں, کی تینوں کے اندر, تینوں اینملزڈا, کیومن اور ٹیگر, تینوں کے اندر, same method, run, same behavior ہے ان کے اندر, run, تینوں بھاک سکتیریل بڑ میں. پہت دک, ایلکتری کے سے بھاگے گی, human, ایلکتری کے سے بھاگے گا اور ٹیگر بہت یہ لکتری کے سے بھاگے گا, رہیٹ, تو اس کا کیا مطلب ہوا? اس کو ہم بس یہ کہتے ہیں, کی ایلک ایلک جانور, ایک ہی بھییور کو ایلک ایلکتری کے سے show کرتے ہیں, رہیٹ, بسیگلی, stimulus, same, run, ان کو بھاکنا ہے, ایک ہی stimulus ہے, لیکن ہم نے کیا, جانور اللہ کر دیے, جو کی ایک same family سے آتے ہیں, وہ اس پہ اللہ اللہ کر دیگے سے ری Act کر دیا, یہ سمجھ گئے, تو یہ ہے polymorphism کا پہلا کیس, ایک اس کا دوسرا کیس بھی ہے, ایک بر وہ بھی بات کر لے تھی اس کی اور پھر ہم بات کریں گے کی polymorphism ہے کیا, چلیمہ اور اس کو repredenum کر کیا سے ہے, تو چلیمہ اب ایک بر دوسرے کیس کی بات کر دیا, دوسرا کیس میں بھی ہم ایک ہی این میں سے کوئی بھی کنی ملو اتھالیتے لیکن ہیومن اتھالیتے ہیں, کیا, اب ام اس کی صرف specifically human کی بات کرتے ہیں, میں نے کہا human vahag sakti run right پر آپ کو بات پت ہے, انسان same behavior کو run کو aalag aalag situation میں aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag aalag bhag aalag There is another scenario.

یہ جو پوالی ہوتا ہے اس کا مطلب کیا ہوتا ہے many right simple English اور مورفیزم کا مطلب ہوتا ہے forms تو بسیگلی پوالی مورفیزم کا مطلب ہوتا some object have many forms تو بسیگلی اس کو سمجھنے گا سمپل تاری کا یہ جو میں آپ کو دو سیناریو سمجھا ہے animal ke اور human ke ki bسیگلی 1 heestimulus پے עלاگالگ animal جو same family سے آتے ہیں وہ allaaglaq taryge سے ریقت کرتے ہیں اور دوسرا 1 heestimulus اگی ایستیمیلوس پے allaaglaq situation لگا لگا لگا تاری کے سریقت کرتے ہیں تو یہ ہے پویری پوالی مورفیزم کی کہانی جو کی ہمیں ریال life میں دیکھنے کو ملتی ہے اگی نمارا کامیں سے ممیک کر رہا پروگرامیم میں تو اب ہی سے پروگرامیم کے دنس میں تھوڑا سا مجھ لیتے ہیں ki پروگرامیم کے دنس میں ہمارے پاس جو پوالی مورفیزم ہوتا ہے اب کیوں کی اب کیوں کی பوالی مورفیزم دو سینی bättreورス کی بات کرتے ہیں تو اس میں بھی ہم دو ہی سینی béورス کی ہے تو ہم کہتے ہیں tam کیا ایک ہوتا ہے ہمارے پاس DNAMEK Pollymorphism اور ایک ہوتا ہے ہمارے پاس Static Pollymorphism اب یہ وہターム سے جو ہم بروگرامیمках لیں ہمیں بیسی کلی کیا کرنہیں پوڑھری مورفیزم کو ریپیزن کرنہیں پروگرامیگ میں تو یہ وہ ٹامس میں ٹامس ہے جو ہم پروگرامیگہ لیی ایس کر رہیں اب دینایمک پوڑی مورفیزم بہی ہے جو میں نے ابھی آپ کو اوپر اگسامپل دیا اس کا سنایریو 1 کا کہ ہمارے پاس ایک اینیمال ہے بیسیگلی اینیمال کہترکہ سکتے ہیں داکھ ایمان اور دائگر اور یہ تینوں ایلاغلک سیٹュیشن میں ایلاغلک طریقے سے ریک کرتے ہیں رنگ پے تو یہ ہے دائیمک پوڑی مورفیزم اور ایلاغلک پوڑی مورفیزم کیاہم نے یہاں دیکھلیا کہ ایک ہی عبجیکٹھیں ہیومن اور ایک ہی مہتھڈے ایک ہیوی رہن پر سیٹュیشنکہ کر بطل جائے ایک پیرامیٹر کرام بطل دیں بس تو وہ لگلک طریقے سے ریک کرتے ہیں تو یہی ہوتا ہے static or dynamic polymorphism چا لو اب جو ہمارہ static dynamic polymorphism ہے بسکلی پروگرامن کے terms میں ہم اسے بولتے ہیں method overloading شاید آپ کوئی پتا ہوگا آپ نے سنا ہوگا Sorry اولٹا لیکن میں اس کو بولتے method overriding اور جو ہمارہ static polymorphism ہے اس میں ہم USA hobbre 법 contre Sergeant Tug Sprewen سید Jadi جیو℃ Naunvenir جسمے ہم نے وہ سارے چیزے رکھی دی ہم نے کہتا ہر گاڡی کے پاس ایک بینٹ ہوگa ایک موڈل ہوگا رائٹ اس کے پاس ایک ایک ایز انجان اون کر کے ایک کریکٹر ہوگa اور ایک کور کریکٹر ہوگa کرٹڈ سپیڈ کا تو املی یہ بات کی دی اور ہم نے یہ بھی دسکchutz کیا تھا کی ہر گاڡی کے پاس کچھ کριیکٹ کر پچھ بھی ہوگa کی ہر گاڡی دی start ہو سکتی аストopt ہو سکتی eksil raid ہو کر سکتی اور بریک کر سکتیہ. پر انٹرسٹنگلی سو چھو ہر گاڈی ایک سلریٹ تو کر سکتی ہے. پر کیا ساہری گاڈی ایک جس ایک سلریٹ کرتی ہوگی. این ہرٹنس والے ایک سمپل میں ہم نے ایک سلریٹ کو اور بریک کو دونوں کو ہم نے میین پیرینٹ کلس میں لکتے تھا اور یہ منا تھا کہ ہر گاڈی ایک سلریٹ تو کرتی ہوگی.

تو اس میں ہم نے یہ منا تھا ہر گاڈی Same طریقے سکسلریٹ کرتی ہوگی. پر پاولی مورفیزم یہ کہتا ہے کہ ہر اوپجیکٹ ایلاؤگل اوپجیکٹ جسیم فاملی سے بلون کرتے ہیں. وہ اوپجیکٹت تیسے دیکٹ کرتے ہیں. سے این بھیور پے.

تو اس ہیرار کی مے بھی ہمارے پاس جو یہاں ہے جس کے دو اوپجیکٹس کے مہنوال کر. اور ایک ہمارے پاس تھا ایلیکٹرک کر. تو اگر آپ دھان سے سو چھو اگر بھیور سیم رہے جو کی ہے. تو اس کی بیٹری پر سنتیج بھی داؤن جائے گی.

پر مینوال کر میں سنیوگا. میں نوگا میں پیٹرول داؤن جائے گا حلکہ پلکہ. باکی یہ دونوں اولاگل اکتری کے ایلاؤگل ایک سلریٹ کرنے کے کار میں. تو بیسکلی پرگرامیگ کے تنس میں امس میں کیا کروں گا.

جو ہم نے اپسٹریکشن وال اگسامپل میں دیکھا تھا. اگر آپ کو وہاں وہ سمجھ نہیں آیا تھا. تو ہم اس کو یہاں سمجھ لیں گے. تو اس کو بیسکلی پرگرامیگ کے تنس میں ایباد کروں گا.

تو میں کیا کروں گا. کار والی کلاس کی اندر. تو اب اگر آپ کو پرگرامیگ مجھا جاتے ہیں. تو بیسکلی میں کیا کروں گا.

جو میں کلاس بناغا کار. تو میں جو کلاس بناغا کار. اس کے اندر میں ایک سلریٹ کو منشان تو کر دنگا. پر دفائنی کروں گا.

بیسکلی موزر دیکلیر کر کے چھوڑ دنگا. اب جونسہ اپجیکٹ کار کا منوال کار کو ریبریزن کر رہے. اس کو میں بولوں ایک سلریٹ تو وہ ایلگ ایٹپٹ دےگا. اور ایلیکٹری کار کو میں بولوں ایک سلریٹ تو وہ ایلگ ایٹپٹ دےگا.

اور یہ جو او ایلگ ایٹپٹ دینامک پولی مورفیزم. یہاں میں نے دینامک پولی مورفیزم کو سابت کر دیا. چلو. کورڈ پیشفٹ ہوتے.

فتافت اور کورڈ دیکھتے ہیں اس کا. جو ہم نے بات کی. وہی ہم نے کود میں کیا ہے. OK.

اپسکرین پے دیکھتے ہیں. یہ اپسکرین پولی مورفیزم کی پوری کلاز. ہم نے سب سے پہلے کیا کیا ہے. وہی same جو اینایٹپٹ دےگا.

کلاز بنائی کار. اور دو کلاز بنائی منوال کار. جو کار کو اینایٹ کر رہے ہیں. اب ہم کار کو ایک بڑ دیکھلے.

بھی ہم نے چارو پرٹیکٹٹٹٹے بنالی ہے. Brand Model is Engine اور Current Speed. OK, same Example as I must have understood. اب.

میں نے کیا کہتا یہ وہ komen method سے جو ہم نے närیٹنزم بھی دیکھا تھا Start Engine, Stop Engine, Every car is there in every car. لیکن, Excell Rate & Break us母 نے انہیٹنز میں اگر آپ کو یادو. لیکن اس میں ہم نے اس کو define نہیں کیا وقت. اس میں ہم نے اس کو Virtual Method بنا کر بنا کے چھوڑ دیا.

Такہ ہے, جس پہ نے اپسکشٹ میں کیا تھا. تو دیدھر اپسٹٹ میتھڑھ فڑ دینامیک پولی مورفیزم اب مینول کار اور ایلیکٹریک کار کا یہ روال ہے یہ دیوتی ہے کی وہ انورٹشل فنشنس کو بیسکلی دیفائنگریں تو مینول کار کو دیکھتے مینول کار کے پاس again جس میں دیسکت کیا تھا ایک پریوٹ کھت کا ممبر ہے کرنٹ گیر اور اس کے پاس یہ کنствیوں گیا اور اس کا SPECIALIZE METhod گیا shift گیر کا اب دیکھتے ہیں کیسے وہ over-ride گرہا ہے اور دینامیک پولی مورفیزم کوشو کر رہے یہاں پہ وہ دیفائنگر دیسکتے ہیں اب دیکھو کیوں کہ یہ мینول کار ہے تو اس کے پاس ایک سلڑڑ کرنے کی پاہر زادا ہوگی تم کرینٹ سپیٹ کو بلسی کلٹوں سے ٹو اینٹی کر دے تھی SIMPAL اب same طریق ہے سے ایلیکٹریکار بھیس کو over-ride کرے گی یہ رہاں our excel rate function اب کیوں کی کلیکٹری کار ہے تو سب سے پیل تو چیک کرے گی کی بیٹری لیوڈ تو نہیں ہو گی جو میں یہاں پیچک نہیں گیا تھا اور جیسے Excel rate ہوگی بیٹری ہم توڈتا دیون کر دیں گے اور current speed کو plus equal to 15 سے بڑھا دیں گے تو یہ ہمارہ 2N excel rate کو basically override کر دیا یہ 2N example ہے dynamic polymorphism کہ یہ اور یہ جس کو ہم method overriding بھی بولتے ہیں اس کے ل้ہ و 2Nm break function تو ہے ہی break function تو ہے ہی اور break function یہ بھی ایک ورچول method بنادیا اور میں گا جس طرح دونوں گاڈیا لگلکتری کے س Excel rate کریں گے اسی طرح سے دونوں گاڈیا لگلکتری سے breaking system بیسگلی define گاڈی Right same ہے بلکل جس سے نکسل rate ایک زمپلیا یہ اگر break martی ہے توپنی current speed بیس سے کم کرتے ہیں اور یہ break martی ہے توپنی current speed 15 رہ سے کم کرتے ہیں so a difference show کرنے کے لے میں break co be override گر دیا وپنے main function دیکھلے ہم نے کیا کرہ دو ترا کی گاڈیا بنیں ایک manual car اور ایک electric car ٹیکے same ہے ہم نے Wagner بنائیں لیکنوال کر میں اور Model S Tesla کی بنائیں electric car میں ہم دونوں میں same function call کرتے ہیں start engine, accelerate, accelerate, break stop engine تو اگر آپ دیکھو گے function دونوں میں same پر output دیکھو دونوں میں اللہ گاڈیا کیا یہ Excel rate کریں گے پر ایک accelerate 15 گلومتر پر ایک پھر یہ 40 ہو جائے گا یہ 030 ہو پھر یہ break یہ regenerative breaking کریں گے electric car ٹیکے جو کی دیکھو common function the engine started engine started and engine turn off engine turn off یہ same output دیں گے یہ method سیدہ ہمارے parent class یہ method ہمارے parent class یہ رہا ہمارے start engine یہ رہا stop engine تو یہ same output دیکھو OK تو دیکھتے static polymorphism کیا اب اگر آپ کو یاد ہو ہم نے scenario consider کیاہ دیکھو ہمارے پس human OK اور اس کے پس behaviour بھی سیم رکھتے ہیں رہا پر human نہ آلاغالک ситуیشن میں آلاغالک تریگے سے بھا گے گا ایک میں اس کے پس ملٹسے خترا نہیں ہے تو وہ دھیرے بھا گے گا و ایک میں اس کے پس خترا ہے اس کے پسے کو ٹیر بھا گے گا ایک پس میں پیرامیٹر کو ایز آرگیوند پاس کرتا ہوں اور میں بولتا ہوں ایک بھولیان ویریابلے جو کی فالز بھی ہو سکتا ہے اور ٹروبھی ہو سکتا ہے اگر فالز ہوگا تو وہ دھیرے بھا گے گا تو وہ تیز بھا گے گا تو بیسی کیا ہوا مثہڈ سیم ہے ایک کی قلاز کے اندر مثہڈ سیم ہے پر اس کے پیرامیٹر بتا لگے بس ہٹنا سگ بات ہوئے اور اس کی وجہ سے کیا ہوا اب وہ اLEGALA ریسپانز ہے تو یہاں تہیدے اب اگر اگر اگر اگر اگر اگر اگر اگر اگر اگر اگر اگر اگر اگر میں نول کار کے پاس ہم نے ایک فنشمنا تھا ایکسل ریٹ میں کہروں ایکسل ریٹ بھی تو کئی طرح کہ ہو سکتے ہیں لیکن اگر ہم ایکسل ریٹ کیا سو تھی گئی گاڈی جب ہم ایکسل ریٹر پی پیڈ پیر مارتے ہیں اگر ہم دھی رے پیر ماریں تو وہ دھی ریکسل ریٹ ہو گئی اور اگر ہم تیس پیر ماریں تو وہ تیس ایکسل ریٹ ہو گئی تو میں کہتا میں دو میتر بناصکتا ہوں ایکسل ریٹ بھی Without any parameter تو وہ Defaultly لدس ایکسل ریٹ ہو گئی بھی اس کے لومٹر پرارت سے اس میں بسے ہو گئی سمے ایک اور ایکسل ریٹ کا فنشنگر بنادوں جو کیک Parameter لیلتا ہے Speed کہ جتری سی پیڈ سے میں نے اس پے پش کیا ہے پیڈر پے اس پیڈ سے ویکسل ریٹ ہو گئی تو اس میں کیا ہوا دے کو دونوں کے Method سے میں دونوں Method سے میں ExelRate دونوں بھی ہیویر سے میں بس بضلا تو کیا بضلا ایک میں میں ایک argument لی ہے ایک میں میں 0 argument لی ہے تو اس کو ہم بلتے ہیں Dynamistatic Polymorphism یعفر Method Overloading اب آپ کو Thurity گلی اگر پتا ہوا یہ تو C++ بات ہے اسم ام زادہ C++ گوصنے نہیں والے ہم تو بس XQAQ Conceptualize V کہ Method Overloading ہم کہتے ہیں کہ Method کا نام سے امرانا چی Return Type بس Number of Argument کم زادہ ہو سکتے ہیں یعفر Argument کے Type بطل سکتے ہیں یعفر C++ آپ کو بتا ہوا گی تو یہ آپ کو بتا ہوا گا Right اور Method Overloading میں جس میں ام نے Dynamist Polymorphism دیکھا تھا اس میں پورا کا پورا Method کا Signature سے امرانا چی Method کا Signature کیا ہوتا ہے Signature بس کا Return Type بھی سیم ہونا چی دونوں کا اس کے Number of Arguments بھی اور Type بھی سیم ہونا چی اور Name Of The function obviously یہ گیر بھی ہو گا یہ Constructed اس میں Start Engine stop Engine اور دیکھا یہ ہے Method Overloading دیکھا جس میں نے بات کیا تھا Excel Rate ایکسل Rate دونوں کا Name سے امرانا چی اس میں ایک بھی Argument 20X Excel Rate اور جس میں Speed جتنی بھی ہماری Speed اس سے Excel Rate اس کے لابا ہمارپس BREAK اور شفٹ گیر ہے تو ویسے اگر ہم اپنی main function دیکھا ایک بھی ایک بھی ایک Excel Rate call کیا Without Parameter اور BREAK کیا اور stop Engine گر دیا تو اگر ہم اس کو فٹافٹ سے چلاکے دیکھ لے تو اگر ہم ایک بات 20 سے ہوا جیسے فرم نے اس کے 40 دیا Speed تو یہاں سے 60 بڑ گیا یہ سیدہ اس کے بعد BREAKING اور Engine turn off as simple as that so this is all about static polymorphism and dynamic polymorphism اس کے لابا ہم میرے پاس آپ کے لیکھا اور Code اب زر آپ نے اس Code کو دیکھئے یہ Code basically static and dynamic polymorphism کو ایک ساتھ آپ کو ایک ہی Code کندر دیکھا رہے ہیں ان فکٹ صرف static and dynamic polymorphism کو ہی نہیں آپ کو میری گٹھا بریپوزیٹری پے جو میں نیچہ شیر کروں گا آپ کو ملی جائے گا اس Code میں آپ دھان سے دیکھو گے نا جب آپ اس Code کو پڑ ہو گے اس کو Open کر گے دیکھا تو اس میں آپ کو abstraction بھی دیکھے گا inheritance بھی دیکھے گا in capsulation بھی دیکھے گا اور دونوں طرح کا polymorphism بھی دیکھے گا تو یہ پر اگر کمپلیڈ اگر بھی بھی بھی اس کو سمجھنے کیا تو ایک بات دیکھتے سیم ہم نے کیا ہم نے کار بھی دو طرح کی کار ایک بھی بھی بھی دیکھتے کار نا بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھی بھھی بھی بھی بھی بھی تو اب MANVAL CARKE PASS ڈپنی SPRESPROPATTY تو HAY SHIFT GAR اور یہ OVERRIDE کر رہی ہے ڈکسلڈ کو دو بار تو یہ میتھڈ OVERRODING کا بیک زمپل ہے اور میتھڈ OVERRIDEING کا بیک زمپل ہے کیا کہ دونوں EXCELLRATE کو OVERRIDE بھی کر رہی ہے اور دیکھو دونوں EXCELLRATE ایک ساتھ ہے ایک کے پاس آرگیمٹ ہے ایک کے پاس آرگیمٹ ہے ایک کے پاس آرگیمٹ نہیں ہے تو یہ میتھڈ OVERRODING کا بیک زمپل ہے اپسٹیکشن کا بھی کر رہی ہے اب دیکھی سکتے ہو اپسٹیکشن کا بھی کر رہی ہے تو ہم نے ان کو ورچول کر دیا کہ میں کہتاں کہ آپ کو بس گاڑی کے بارے میں یہ پہتا آنچی گاڑی EXCELLRATE کیا سو تھی اب ایک کے دیفینیشن ہم پر ایکٹیکلی کسی MANVAL CARKE ایکٹریک کر رہی ہیں وہ انڈردی ہوت چھوپی ہوئی ہے وہ آپ کو دیکھنے کی ضرط نہیں ہے تو یہاں پہسٹیکشن کا بھی ایک زمپل ہو گیا انہریٹنز کی ایک زمپل تو آپ کو دیکھی رہی کہ دو ایک MANVAL CARE اور ایک ایک ایک دیکھر کر رہی دونوں ایک بسیگلی کیا ہے ایک طرح کی CARE اس کو انہریٹ کر رہی ہیں اور last but بچہ جو ہمارہ پاولیمورفیزم تھا وہ ہم نے یہاں دیکھ لیا کہ پاولیمورفیزم کیا کہتا دیتا سکیورٹی اب یہ کی ایلیکٹریکار ہے تو جو ایک سلڈ کرتی ہے وہ کم سپیڈ بیکسلیٹ کر پاہتی ہے اور یہ سپیڈ بیکسلیٹ کر پاہتی ہے اور MANVAL CARE زاد ایک سلڈ کر پاہریتی اور اس میں بھی ہم نے BREAKFUNCTION اور last میں ہم نے MANVAL CARE میں دو طرح کی CARE بنا دی ایک MANVAL CARE ایک ایلیکٹریکار اور انویہی ایک فنشنز رن کر دیئے start-injen excel-rate break stop-injen اب دیکھو یہ میتھڈ over loading اور کیوں کی دونوں دونوں اولا گا اوٹپٹ دیں گے تو میتھڈ over riding اگسامپل بھی ہو گیا تو کہاں اس کو رن کریں just a second تو کہاں اس کو رن کریں تو اب دیکھ سکتے ہو ہمارے پاس یہ اوٹپٹ آ گیا ایک 20 گلومیٹر پرار سکسلڈ کر رہے پر ایکسل 15 سے کر رہے اس کے بعد یہ 40 ہو گیا یہ سپ 30 ہو پیا so یہ پورا گا پور اگسامپل ہے جس سے آپ کو I guess سارا گا سارا اوپس سمجھ آ گیا ہو گا یہ ایک لوگ تھا ایک زمپل کافی تھا چاروں کے چاروں پیلڈس کو ایک ساتھ سمجھنے کے لئے پر اس ایک زمپل کو بلڈ کرنے کے لئے ہمیں ایک ایک کر کے چاروں کو سمجھنہ پڑا اب ہو سکتے ہیں جب آپ اپسٹریکشن بڑھ رہے تھے تو آپ کو ایک دم سے ساری چیدے کلیر نہ ہو گیا پھر دیرے دیر کچھ دیں کچھ دیں کچھ دیں کچھ دیں کچھ دیں کچھ چیدے اینھرٹنس پہر ساری چیدے پاولی مورفیزم پیگے کی کلیر ہو گیا اور ابھی بھی ہو سکتے ایک دو داغ سپ کے بچے ہو پر کہنے گا ہمتلا بس یہ تھا کہ جب آپ پیلڈس و فوبس کو ایک بر پورا پڑھے تھے ہو اور ایک ایک ایک زمپہ لقتتے ہیں جس میں وہ چاروں کے چاروں ایک ساتھ ایوز ہو رہے ہیں اب آپ اس کو بہت اچھ دریلےٹ کر پاتے ہو ریل و الڈے اور سمچ پاتے ہو کہ ہم پیلڈس اف اس میں اگتیلے کیا رہے تھے اور یہ اس کے ایک ایک زمپہ لہیں تو ایھ ہو آپ کو یہ بیڈیو پسند آیا گی اس کے لئے لازت میں جاتا ہم آپ سے بس یہ کہنا چاہتا ہوں کہ جتنا بھی ہمیں کلیر کوٹ لکھا ہے وہ सہ آپ کو میری گٹھہ بریپوزٹری میں مل جائے گا جس کا لیکن میں дисکریפ션 میں دے دوں گا آپ وہاں جانا آپ سارا کا سارا سورسコード وہاں سے دیکھ سکتے ہو آپ اس میں چینجز بھی کر سکتے ہو آپ اسے سامجھ بھی سکتے ہو آپ اس میں کچھ نہیں کوٹھ بھی اپنے you know practice کے لئے خود کے کوٹھ میں پہلے لکھ سکتے ہو تو یہ سب چیزے آپ بلکل کروں میں آپ کو سجس کرتے ہو چلو last میں آپ کو ایک homwork بھی دے دیا ہمیں ہم نے یا دا میں méthod over loading کی بات کی تو آپ کہ گئے homwork ہے کہ مجھے آپ کو بتانا ہے آپ کو مجھے بتانا ہے سواری کی operator over loading کیا ہوتی ہے C++ میں operator over loading use ہوتی ہے اگر آپ کو بتاو ایک تو آپ کو بتانا ہے کمینٹ سکشن میں مجھے کی operator over loading کیا ہوتی ہے اور دوسرا آپ کو مجھے بتانا ہے کہ ایک اور کوئی Langvages جا جا وپائی تھن ان سب میں operator over loading کو support QNI کیا گیا اور C++ میں کیوں ہوتی ہے چکے so this is the question for you باکی آپ کے کوئی بھی دوٹوں oops a related or first lecture alleldy gay introduction a related so آپ اپنا کمینٹ سکشن میں doubt ضرور پوچنا اس video میں بس اتنای ہم ملتے نکس video میں thank you so much

Lesson FAQs

What is Inheritance & Polymorphism in OOPs about?

حنجی تو کریں start so welcome back to our LLD playlist last video if you remember we had seen two objects oriented programming and two pillars which were abstraction and encapsulation aside from this two pillars last video which are inheritance and polymorphism which we

What key concepts are covered in this lesson?

The lesson covers System Design, Low Level Design, High level Design, System Design for Beginner, System Design for advance level.

What should I learn before Inheritance & Polymorphism in OOPs?

Review the previous lessons in System Design Full Course, then use the transcript and key concepts on this page to fill any gaps.

How can I practice after this lesson?

Practice by applying the main concepts: System Design, Low Level Design, High level Design, System Design for Beginner.

Does this lesson include a transcript?

Yes. The full transcript is visible on this page in indexable HTML sections.

Is this lesson free?

Yes. CourseHive lessons and courses are available to learn online for free.

Continue Learning

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Lessons

Related Courses

FAQs

Course Hive
Download CourseHive and keep learning anywhere
Get App