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.
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
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++
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.
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::
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..
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.
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...... :)........
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 !!!!!!
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
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.
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.
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...!!!
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++
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ogUtrqDmiqs.html Azure and Azure DevOps interview with #wipro and #microsoft especially for Midlevel and Beginners
@@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
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.
Brother, I really felt this was not well explained by you! Maybe I'm wrong because so many here are praising you , but I gave my best to this lecture and think it's so so so confusing!
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.......
Padding meaning in Urdu " Bahrti - karna " matlab ka add karna char ' A '; ' A ' ki value hexa-decimal ma 10 hoti ha A = 10; 10 ko binary ma convert karana ka liya hama 2 ka sath LCM lana ho ga A = 10 = (1010) or is ki base 2 sa multiply karan ga In Right-side-start 0 = 2 ^ 0 = 1 1 = 2 ^ 1 = 2 0 = 2 ^ 2 = 4 1 = 2 ^ 4 = 8 so 1byte = 8 bits = 4 parts ( 1, 2 , 4 , 8 ) So A will be store in 1 and 2 , 4 , 8 is empty so In case off padding its also be store or add empty values
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
bhaiya aapko na isse 2 part mein padhana chayea tha ek saath access modifier constructor sb bta diye to the point bolu to muze constructor samaz nhi aaya ab dubara dekhunga but aage se 40-45 min ka hi video bnana
Great video and I am just surprised that someone can maintain energy and focus for 90 minutes while explaining OOPs to a camera. I need to take breaks just to watch it completely once.
29:03 pe jo aapne boli hai ki paid me bhi nhi hoti hai ekdm shi baat hai ...koi structure/class padding nhi sikhata ...jbki interviewer mje lene ke liye puch hi leta hai.
Please add the the explanation of greedy alignment and padding in next video,unable to get the clear understanding of it. But want to know so please add it to next video.It's a request.
Greedy align and padding i searched myself and got to know that Our operationg system is of 32/64 bits And if our OS is 64 bits it means that the compiler will read 8 bytes at a time if OS of 32 bits compiler will read 4 bytes at a time Here as we have one int and one char which mskes up 5 bytes the rest 3 bytes will be added as padding so that compiler can read 8 bytes easily ... This also leads to memory wastage ... This is what i got to know after searching .... Please correct me if i sm wrong
Hi, As you’ve interviewed with DE Shaw, you have a deep understanding of the extent to which OOP concepts are asked in their interviews. Could you please suggest additional resources for mastering OOP?
Bhaiya, actually constructor is not only called while creating object but the time of updating the values also, I am sharing the code #include using namespace std; class con { public: con() { cout
class A { int a; char b; short int c; char d; }; SIze allocating in this set of members is - 12 bytes. Can anyone please explain this ? According to my understand it must allocate 8 bytes. word size - 4 bytes. 1 - a a a a 2 - b c c d