1. Padding is introduced in memory allocation to ensure proper alignment of data within structures. CPUs have specific memory alignment requirements for different types of data. When you have a structure containing different data types, the compiler might insert "padding bytes" between members to align them according to the CPU's requirements. 2. Greedy alignment refers to the practice of arranging the members of a structure or class in such a way that padding is minimized. By placing members with larger alignment requirements before those with smaller alignment requirements, you can potentially reduce the amount of padding required. In languages like C++, where memory layout has a significant impact on performance due to cache lines and memory access patterns, arranging members to minimize padding can lead to better memory utilization and potentially improved runtime efficiency.
That concept of padding and greedy alignment was so cool . I'm watching this lecture after college and I was a little dizzy , but after that I'm ready to go for another hour .
"Grid Alignment" refers to arranging data members according to the system's memory boundaries, and "Padding" involves adding extra bytes to achieve proper alignment of data members within classes or structures in Object-Oriented Programming.
Homework Solutions - 01:16:47 1. **`const` Keyword**: The `const` keyword in C++ signifies that something cannot be modified. When applied to variables, it means the variable's value can't be changed. For pointers, it can mean that the pointer can't change what it points to or that the data it points to can't be changed, depending on its placement. ```cpp const int x = 10; // x cannot be modified ``` 2. **Using `const` in Object Creation and Member Data**: - **Object Creation**: When you declare an object as `const`, it means you can't modify any of its data members (unless they are declared as `mutable`). ```cpp const MyClass obj; // obj's members cannot be modified ``` - **Member Data Types**: When a class data member is declared as `const`, it means that member cannot be modified after the object is constructed. ```cpp class MyClass { private: const int x; // x must be initialized in the constructor and cannot be modified afterwards }; ``` 3. **`const` Functions**: A member function that is declared `const` promises not to modify any non-mutable member variables of the object for which it's called. This allows you to call the function on a `const` object. ```cpp class MyClass { public: int value = 0; int getValue() const { // A const member function return value; } void setValue(int v) { // Non-const member function value = v; } }; const MyClass obj; int x = obj.getValue(); // OK to call // obj.setValue(5); // Error, because setValue is not a const function ``` 4. **Initialization List**: Initialization lists are used in C++ to directly initialize data members of a class. They are particularly useful for initializing `const` members, member objects without a default constructor, and reference members. ```cpp class MyClass { private: const int x; int &y; // Reference to an integer public: MyClass(int value, int &ref) : x(value), y(ref) { // x and y are initialized using an initialization list } }; int main() { int externalInt = 5; MyClass obj(10, externalInt); } ``` In the above `MyClass`, the `x` member is a `const` integer and must be initialized using an initialization list in the constructor. The `y` member is a reference and also must be initialized using the initialization list.
It took me a day to complete this. There were so many things to tinker with. I solidified what I learned here. Did quite a lot of experiments. SHAKTIMAN++
After 3 months my placement are coming and this course is very helpful in reversing the concepts and making me more confident In coding . I will recommend this channel to my juniors for learning dsa at an excellent level. Thankyou sir for making this course
i have never watched an educational video so long in one go .This felt like a movie which not let you leave your seat .. So good and kept up hold to study for long hour::
aapne paul ka hoa yaaad dualaya bhot achha lga sunke... thats why i love your content sir... its not just plain studying.. you relate everything.. nothing seems boring and hours and hours go away without even noticing..... god bless you siir !!!!!!
You are the gift to programmers sir many many thanks to you.. May Allah keep you happy and healthy ,wealthy(Ameeen)... Sir Your teaching way is just Amazing. I have No words for your teaching..
usually i don't comment on any video.. but this time can't stop my finger....thank you thank you so much sir ... for making my concepts clear and giving me confidence...... :)........
Much awaited video aa gayi hai, bcoz ab tak sirf theory padh rahe the but is bar interview me kaise pucha jata hai, uske according padhne wale hai. So excited for this.
brooooo you are just awesome .....your teaching is too good i am able to understand everything thankuuuuu... today is 5/02/2024 currently studying it for SEM 3rd exams but after my exams i will learn c++ then will do DSA from you .......i promise to be serious about my future
This is the best explanation of oops concept..!! Startingly i got rejected in technical rounds because i don't know much about oops..!! When i completed these two videos of oops then i'm getting qualified in technical and getting rejected in hr rounds.. double oops...!!😂..!! Finally i made it..!! And got selected..!! Thank you so much...!! Your whole series of this DSA concept is awesome..and this oops is just fab...!!!
After watching almost every single video about oops on youtube and still not understanding anything from it ..finally I found this video which is damnnnn useful and understandable😄like how is he able to explain these concepts in such a better way😳Respect for this Sir who is doing such a great and useful job...Just loved it😀💗💓
1. Padding Definition: Padding is the practice of adding extra bytes to data structures to align them in memory according to the system's requirements. Purpose: Helps optimize memory access speed. Most processors access memory more efficiently when data is aligned on specific byte boundaries (e.g., 4, 8, or 16 bytes). Example: struct Example { char a; // 1 byte int b; // 4 bytes }; Without padding, this struct would take 5 bytes. However, with padding, it may take 8 bytes due to alignment, so int b is stored at a 4-byte boundary. 2. Greedy Alignment Definition: Greedy alignment is a strategy to organize and align data members of a structure to minimize wasted memory due to padding. Purpose: Reduces overall memory usage by arranging larger data types first to minimize the need for padding. Example: If you have a struct with char, int, and double, placing double first, then int, and finally char minimizes padding and optimizes memory layout.
Awesome, congrats bhaiya❤️🎉 ‼️One complain from you bhaiya, You don't accept linkedIn request!👀 How would we ask for referral from you if you don't accept?😔 You said in previous live that you would reffer us, in future!🤩
Thanks bhaiya for teaching OOP's concept in so much depth and details... there are so many things which are new to me and I have understood them.... joshHigh++
@@aniketmukhopadhyay2271 yes they are enough but make sure to practice a lot and clear your doubts while practicing at that time only by yourself and you are good to go not only for exams but for anything
Padding is used to prevent the unnecessary wastage of CPU cycle by creating empty block in memory. But Greedy alignment ka koi refrence nahi mil raha hai bhaiya.
Hello sir Just a small suggestion. Can you also share the resources which you follow to prepare for videos, so that we can also deep dive into the topic apart from watching video.
Bhaiya sahi chl rhe hai bss ese he m aur mere sath k babbar class k mates agle 6 month m ya 1 year koi achi job fod dengey and sach bolu toh app he sabsi motivation ho reason btane ki jaruart nh but fir bh bta deta hu continues classes till today esa koi nh krta aur nahi ab tk mene koi dekha hai thankyou from one of your student!! vase job k baad apke channel m interview toh logey na mera........?? till that day let's learn something new today too.......
Timestamp- 9:15 Please talk about structural padding and packing sizeof will not give 5 if class contains an int followed by a char or vice versa This video is very helpful. Thanks Babbar
well well well, I see you are a man of culture as well. I burst into laugh when you said paul and it's hoaaaa.....😂😂😂😂 Thanks for the amazing content BTW.
1. Padding is introduced in memory allocation to ensure proper alignment of data within structures. CPUs have specific memory alignment requirements for different types of data. When you have a structure containing different data types, the compiler might insert "padding bytes" between members to align them according to the CPU's requirements.
2. Greedy alignment refers to the practice of arranging the members of a structure or class in such a way that padding is minimized. By placing members with larger alignment requirements before those with smaller alignment requirements, you can potentially reduce the amount of padding required.
In languages like C++, where memory layout has a significant impact on performance due to cache lines and memory access patterns, arranging members to minimize padding can lead to better memory utilization and potentially improved runtime efficiency.
thank you very much 👍👍
Shukriya janab Love from Pakistan 🇵🇰
Thanks bhai
Thanks brother 👍
That concept of padding and greedy alignment was so cool . I'm watching this lecture after college and I was a little dizzy , but after that I'm ready to go for another hour .
Worth watching for 1.5 hr.
Understood Everything.
Great 👍.
Keep it up.
"Grid Alignment" refers to arranging data members according to the system's memory boundaries, and "Padding" involves adding extra bytes to achieve proper alignment of data members within classes or structures in Object-Oriented Programming.
1:01:00 solution :- #include "include this library" to your program
Homework Solutions - 01:16:47
1. **`const` Keyword**:
The `const` keyword in C++ signifies that something cannot be modified. When applied to variables, it means the variable's value can't be changed. For pointers, it can mean that the pointer can't change what it points to or that the data it points to can't be changed, depending on its placement.
```cpp
const int x = 10; // x cannot be modified
```
2. **Using `const` in Object Creation and Member Data**:
- **Object Creation**: When you declare an object as `const`, it means you can't modify any of its data members (unless they are declared as `mutable`).
```cpp
const MyClass obj; // obj's members cannot be modified
```
- **Member Data Types**: When a class data member is declared as `const`, it means that member cannot be modified after the object is constructed.
```cpp
class MyClass {
private:
const int x; // x must be initialized in the constructor and cannot be modified afterwards
};
```
3. **`const` Functions**:
A member function that is declared `const` promises not to modify any non-mutable member variables of the object for which it's called. This allows you to call the function on a `const` object.
```cpp
class MyClass {
public:
int value = 0;
int getValue() const { // A const member function
return value;
}
void setValue(int v) { // Non-const member function
value = v;
}
};
const MyClass obj;
int x = obj.getValue(); // OK to call
// obj.setValue(5); // Error, because setValue is not a const function
```
4. **Initialization List**:
Initialization lists are used in C++ to directly initialize data members of a class. They are particularly useful for initializing `const` members, member objects without a default constructor, and reference members.
```cpp
class MyClass {
private:
const int x;
int &y; // Reference to an integer
public:
MyClass(int value, int &ref) : x(value), y(ref) {
// x and y are initialized using an initialization list
}
};
int main() {
int externalInt = 5;
MyClass obj(10, externalInt);
}
```
In the above `MyClass`, the `x` member is a `const` integer and must be initialized using an initialization list in the constructor. The `y` member is a reference and also must be initialized using the initialization list.
thank you so much..
Chatgpt
bro which IDE he is using
@@amarjitrohit8819 Visual Studio Code
It took me a day to complete this. There were so many things to tinker with. I solidified what I learned here. Did quite a lot of experiments.
SHAKTIMAN++
bhai toh lagataar ek baar mai dekha kyuki merko pura din laga notes banana smjhna?
Sir, you are great. You've taught OOPS in such a way that, no one has ever taught me. Superb teaching method...
Bhai suno tumse kuch puchna tha??
man as you said earlier this series is absolutely top-notch and the best.
Just revising all topic in better way through these videos💯
After 3 months my placement are coming and this course is very helpful in reversing the concepts and making me more confident In coding . I will recommend this channel to my juniors for learning dsa at an excellent level. Thankyou sir for making this course
Mine tooo
You are too late man.These lectures are just basic
@@111rhishishranjan2 dont demotivate others, anything can happen with hardwork
Engineering will always be better
@@111rhishishranjan2 Lol. People crack job interviews without learning OOPS also, while you are saying this in not enough.
Never compromised with content, does't matter how much time needed..
Great work bhaiya :)
i have never watched an educational video so long in one go .This felt like a movie which not let you leave your seat .. So good and kept up hold to study for long hour::
aapne paul ka hoa yaaad dualaya bhot achha lga sunke... thats why i love your content sir... its not just plain studying.. you relate everything.. nothing seems boring and hours and hours go away without even noticing..... god bless you siir !!!!!!
The best thing about your courses is their 'simplicity'...
that is what Indians want now...
so your courses stand out !!
Never seen oops concept like this you explained every concept deep
And here comes the video that we were waiting for since last couple of days ...!! 😅😁🙌🥳
Where is the complete notes bro? Please reply🙏🙏🙏
Very understanding videos.... Examples are real life thing.... Anybody can understand your video bhaiya💗❤️
Maza aa gaya..bohot kuch sikha aur samjha.. badhiya content.
Respect and Efforts++ 🔥✅🙌🏻
Hmm❤
You are the gift to programmers sir many many thanks to you.. May Allah keep you happy and healthy ,wealthy(Ameeen)...
Sir Your teaching way is just Amazing.
I have No words for your teaching..
Bhaiya you made me fall in love with your series🤩!!! watched 10 videos in a single row.....just love the way you teach in a simplified way.
PIRO COMDER SPOTTED
Ek hi poori nahi ho pati, yaha 10 in a row... Kaise kar lete ho bhai/behen ?
@@nareshvasuja3506 uss din hi dekh pai thi fir bimar hogyi😂....ab thoda ye task mushkil lag raha h
@@kirtiverma4924 😅😂😂
@@kirtiverma4924 Iss video ko samajne mai merai ko 2 din lag gye pura keetai krrtai 🥲🥲🥲🥲🥲
really love the consistency os+ds on track thank you so much
Most awaited session from last couple of days Bhaiya......
Awesome lectures ....
All d best bhaiya,🤗🤗🤗
YES he is great one, DIDI
Friend function sikhaya hai kya live Babbar bro me
OS ka intro ek number bhaiya ❤️🎉
Osm bhaiya❤️🔥🔥🔥🔥🔥🔥🔥🔥
watched this video 2 times and now i feel lot of comfidence when someone talks about OOPs 😃😃
@007_roushankumar7 can you explain about double pointer in oops😂😂
usually i don't comment on any video.. but this time can't stop my finger....thank you thank you so much sir ... for making my concepts clear and giving me confidence...... :)........
Unbelievable teaching experience such a nice teaching way 😃😊
Much awaited video aa gayi hai, bcoz ab tak sirf theory padh rahe the but is bar interview me kaise pucha jata hai, uske according padhne wale hai. So excited for this.
you are amazing person with clear cut knowledge and style of course is superb. serving Nobel cause of education for all.
respect for you 🏅🥇
really great
The depth of the conceptsis just amzing
Simply Wow! Get to learn some new concepts in addition to what i have learned.
All things are clear and concise....Thanks Babbar Bhaiya
brooooo you are just awesome .....your teaching is too good i am able to understand everything thankuuuuu...
today is 5/02/2024 currently studying it for SEM 3rd exams but after my exams i will learn c++ then will do DSA from you .......i promise to be serious about my future
placement hui bhaii??
Paul's supperpunch,jin kazama everything was just ❤
Thanks, please keep releasing DS video daily without break 🙏
This is the best explanation of oops concept..!! Startingly i got rejected in technical rounds because i don't know much about oops..!! When i completed these two videos of oops then i'm getting qualified in technical and getting rejected in hr rounds.. double oops...!!😂..!! Finally i made it..!! And got selected..!! Thank you so much...!! Your whole series of this DSA concept is awesome..and this oops is just fab...!!!
Where did you get the job? Did you just watched only this playlist?
Where did you get placed.... Did you follow just this playlist or something extra too @priyabharti2818
Finally! Oops concept is here. Op consistency 😎
After watching almost every single video about oops on youtube and still not understanding anything from it ..finally I found this video which is damnnnn useful and understandable😄like how is he able to explain these concepts in such a better way😳Respect for this Sir who is doing such a great and useful job...Just loved it😀💗💓
U can use ctrl + '/' to comment multiple lines and ctrl + 'L' to clear the terminal bhaiya. Loving your course.
Code with Harry se sikhe ho kya bhai 😀
Very much impressed with the concept of padding and greedy alignment. Understood something new🙌🙌
I really love this series ♥️ thanks sir
You are really a leagend 👍🏻
1. Padding
Definition: Padding is the practice of adding extra bytes to data structures to align them in memory according to the system's requirements.
Purpose: Helps optimize memory access speed. Most processors access memory more efficiently when data is aligned on specific byte boundaries (e.g., 4, 8, or 16 bytes).
Example:
struct Example {
char a; // 1 byte
int b; // 4 bytes
};
Without padding, this struct would take 5 bytes. However, with padding, it may take 8 bytes due to alignment, so int b is stored at a 4-byte boundary.
2. Greedy Alignment
Definition: Greedy alignment is a strategy to organize and align data members of a structure to minimize wasted memory due to padding.
Purpose: Reduces overall memory usage by arranging larger data types first to minimize the need for padding.
Example:
If you have a struct with char, int, and double, placing double first, then int, and finally char minimizes padding and optimizes memory layout.
With these kind of videos no one can stop getting me placed in top MNC's.
Best"est" Lecture on OOPs by far bhaiya!Hats off👏
Keep the pace high!!
As we are getting back to online classes I can give maximum time to this.
Present bhaiya
Lots of love❤
which sem?
@@KajalSinghshine 1st semester
@@sherebanoburhani8939 bhai life enjoy kro 1st sem se kn pdta h
@@only_for_fun1234r hehe
ruclips.net/video/QTaiF8N6i3Y/видео.html
Finally I got this topic. I am waiting for this topic since last couple of days.....🙏 Thank u bro.....🙏🙏🙏😂😂🥳🥳
Learn new concept after watching 3 4 videos from other ytubers ,u r great sir
Your method of teaching is outstanding sir you deserve millions likes and subscriber👀🔥
best video for learning oop. i have seen many channels but this one is flawless.
best teacher on youtube for coding
I really want to thank you for making combined play list for cpp and dsa thank you so much really appreciated once again thank you
Thank you sir apk is lec say mera oop ka paper acha hogea, pehli bar mujay oop programming sai say smaj ai hai ❤🎉🎉
Finished watching the entire video. The content was awesome. Keep rocking!!
best tutor online, bhaiyya saare doubts in depth clear hogaye!
Padding vala bahut sahi bataya...kabhi kisi ne YT me nahi bataya.
Going to see it tomorrow but thank you so much for the consistency brother, god bless you.
Finally understood the actual meaning of (this pointer) after so many years!!!
Awesome, congrats bhaiya❤️🎉
‼️One complain from you bhaiya, You don't accept linkedIn request!👀 How would we ask for referral from you if you don't accept?😔 You said in previous live that you would reffer us, in future!🤩
Late ho to kya dekhna to hai he 🔥🔥
Present sir
Thanks bhaiya for teaching OOP's concept in so much depth and details... there are so many things which are new to me and I have understood them.... joshHigh++
ruclips.net/video/ogUtrqDmiqs/видео.html Azure and Azure DevOps interview with #wipro and #microsoft especially for Midlevel and Beginners
Bro , is this two videos are enough for semester exam?
@@aniketmukhopadhyay2271 yes they are enough but make sure to practice a lot and clear your doubts while practicing at that time only by yourself and you are good to go not only for exams but for anything
bhaiya... bhaiya phle majburi m shuru kiya tha lekin ab mja aane lga h
you are such an amazing teacher.!!
Is video ko dekh ke logo ki placement lagi hai bhaiya Dil se respect++
Thank you, sir, for such awesome lectures, it really helps a lot in the time of need...
jabardast video hai good explanation 👌👌👌👌👌👌👌👌👌👌👌
bhaiya your oops series is one of the best on you tube
bty sir aapne videos ni dale kuch dino se ?... just asking.
Waiting the video only👍👍
Bhot maja ane wala hai❤️❤️
Present sirji 👍
Padding is used to prevent the unnecessary wastage of CPU cycle by creating empty block in memory.
But Greedy alignment ka koi refrence nahi mil raha hai bhaiya.
Also called as Data Structure Alignment, just search its available on GFG.
greedy alignment mtlb ki data type ko particular way me alighn krna taaki vo minium processing cycle me jyada data types ko fetch aur process kr paye
It’s on javatpoint
Thank you so much bhaiya apka channel crores m views paae aur hindustan k Engineer to skills pradan kre
Hello sir
Just a small suggestion. Can you also share the resources which you follow to prepare for videos, so that we can also deep dive into the topic apart from watching video.
vs code
u will get in google
Great explanation of OOPS.🤩🤩🤩🤩🤩🤩
Keep up the good work
Meanwhile Ramesh ,"Abe yaar main itna famous hogya" 😂🤣😂😂
😂😂
Thanku so much sir you are so amazing sir love u❤❤❤
Sir mn nay bhut sy teachers sy lacture leay h but you are the best ❤❤
Meri kal exams hai aur Mai Aaj lecture dekh Raha hu 😅😢😅
Meri be kal exams hain 😅😅
@@user-os2jb2hq5fkaisa gya exam tumhara
Meri abhi 2 ghante mein hain.😅
😂us
Meray 1 gheintay bad
Macha diya bhai !!! Bahut gazab
wasted 1 hour and not learnt something , sorry bhaiya but constructor is something complicated and pls tell the need before explaining it
Constructor is used to initialize object without using external methods
He has explained everything very nicely
Bhai kaunse channel par badhiya se sikhaya hai constructor??
Pls batana agar pata hai toh
Code with Harry
Bhai to pehlii basic seek lay phir akay constructor dhek layna
thanks love babber bhai for this quality education in the youtube
51.41
gajb bazzati hai
29:09 it seems like some important message had been seen by sir🌻
Bhaiya sahi chl rhe hai bss ese he m aur mere sath k babbar class k mates agle 6 month m ya 1 year koi achi job fod dengey
and sach bolu toh app he sabsi motivation ho reason btane ki jaruart nh but fir bh bta deta hu continues classes till today esa koi nh krta aur nahi ab tk mene koi dekha hai thankyou from one of your student!!
vase job k baad apke channel m interview toh logey na mera........??
till that day let's learn something new today too.......
litterly i saw this 3 times for more and more better understanding
jiska thaa, saalo se intezar wo video aa gayi aa gayi ...... 😀😀
watched till end! kaffi lamba tha but worth it tha time invest krna isme
Bhaukal macha diye bhaiya ji 😂🔥🔥🔥 kbse wait kr rhe h
*MORE INTERESTING THEN MOVIES *😅😅😅
one of the finest opps video on entire youtube hats of your ser 💥
ek dam Garda uda diye bhaiya aap......😊
Finally return of 1 hour video... Really missing these videos..
Boht badhiya ,Boht badhiya.
Amazing bhai jo mujhe koi ni smjha paaya aapne smjha diya🥲
aap editor konsa use kr rahe ho
Very good video of oops for a beginner.
The best OOPS video I ahve watched
Timestamp- 9:15
Please talk about structural padding and packing
sizeof will not give 5 if class contains an int followed by a char or vice versa
This video is very helpful. Thanks Babbar
very good content
must watch
Bhaiya ,Your video is always very Good ,
I have learned oops in python and this lecture cleared my concept about oops in c++. Im starting DSA in c++
well well well, I see you are a man of culture as well. I burst into laugh when you said paul and it's hoaaaa.....😂😂😂😂
Thanks for the amazing content BTW.
Outstanding teaching style LOVE U
Kya jabarjast padhate ho bhaiya 🥳
very informative lecture, thank you bhaiya!