Advanced Inheritance & Polymorphism - example with Array of Objects (in-depth Data Structures & OOP)

preview_player
Показать описание
This video provides an in-depth explanation of the relationship between Arrays of objects and OOP concepts such as Inheritance and Polymorphism. It is a programming tutorial designed to teach you about data structures, object-oriented programming, and best practices for writing code. Through a practical example, you will learn how to create arrays that hold a collection of different objects. By the end of this coding exercise, you will have a solid understanding of how to implement parent-child relationships between classes and write reusable code. Additionally, you will learn how to implement polymorphic behavior and write efficient code.
To put your knowledge into practice, I have also prepared a practical task for you. This hands-on challenge will ensure that you understand these concepts and are able to use them in your own programming projects.

📚 Learn how to solve problems and build projects with these Free E-Books ⬇️

Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

I use it to enhance the performance, features, and support for C, C#, and C++ development in Visual Studio.
It is a powerful, secure text editor designed specifically for programmers.

However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇

Related videos:

CONTENTS:
00:00 - What you will learn in this video?
02:06 - Explaining initial code
03:33 - What is Inheritance?
03:52 - Inheritance implementation
06:48 - What are virtual methods and abstract classes?
09:37 - What is polymorphism?
10:39 - Polymorphism implementation
15:23 - Memory deallocation
16:26 - How to deallocate memory?
17:48 - Static code analyzer
18:35 - Practical task for you
21:18 - Bloopers

Add me on:

*******CODE IS IN THE COMMENTS*******
Рекомендации по теме
Комментарии
Автор

📚 Learn programming with these Free E-Books ⬇
Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

Code:

#include <iostream>
#include<algorithm>
using namespace std;

class Student {
public:
string Name;
int Age;
char Gender;

virtual void study() = 0;// a pure virtual method
};
class ProgrammingStudent : public Student {
void study() {
cout << "Pracice programming" << endl;
}
};

class ArtStudent : public Student {
void study() {
cout << "Pracice painting" << endl;
}
};

class MusicStudent : public Student {
void study() {
cout << "Pracice singing and play an instrument" << endl;
}
};

int main()
{
// Create an array of pointers to Student
Student* students[3];

// Assign new derived class objects to the elements
students[0] = new ProgrammingStudent();
students[1] = new ArtStudent();
students[2] = new MusicStudent();

// Use the students
for (int i = 0; i < 3; i++) {
students[i]->study(); //watch the magic happen
}

// When done, delete the dynamically allocated students
for (int i = 0; i < 3; i++) {
delete students[i];
}

cin.get();
}

CodeBeauty
Автор

standing ovation for this video, your effort in simplifying these concepts deserves a big round of applause

amelccc
Автор

your breakdown of arrays of objects, along with insights into polymorphism and inheritance, has given me a solid grasp on these topics, thank you Saldina

codeoasis
Автор

You're an excellent teacher, and have a great gift to explain these complex topics so well. I admire you even more now that I know English is not your native language!

dundyd
Автор

just wanted to drop a quick shoutout for your video, your teaching style rocks, many thanks

deanmorrison
Автор

hey there Saldina, your video seriously helped me wrap my head around complex programming topics such as this one, just wanted to say thank you <3

Sam-kii
Автор

can't thank you enough for this video, you are truly empowering me on my coding journey. Fantastic instructor

MilesGerome
Автор

Thanks, watching all these series of videos related to array of objects

anwar
Автор

Thank you for this insightful lesson your coding videos are incredibly valuable for learners like me.

lamienali
Автор

excelent explanation as always, thank you Saldina

milkamilkica
Автор

i wish there is more instructors like you, thanks <3

l.p.
Автор

Excellent explanation on inheritance and polymorphism! Thank you so much.

OzzFan
Автор

great content Saldina, superb explanation, thx <3

hilgicamala
Автор

Hi, can you please make a video about Lybiscovist Substitution Principle? This is deeply related to this topic.

pedrolobo
Автор

Your videos are filled with highly inspirational and generous instructions. Thank You Saldina Thank You. You’re by far the best most legendary C++ instructor I’ve ever met over the internet. Be well Saldina. Peace and Blessings through our Blessed Mother.

HexShank
Автор

Could you possibly delve into the use of different scripting languages like Python and C++ to create a login page?

lamienali
Автор

just what i needed, thank you Saldina

nvusb
Автор

I thought English was Saldina's native language. What IS her native language then🤔?

christopherrice
Автор

Well it is done. I watched all of the oop lessons here. It was totally a masterpiece. I will do more practice and in a few days I will start data structures playlist in your channel. (maybe pointers as well) Thanks for the all cool informations, It was the best so far I have ever seen, u r great!

salihbarknakkaya
Автор

I didn't know I could do arrays of pointers for every object I make. This is super helpful thank you so much, learned a lot just from this vid🎉

johnmichaelisaac