Dynamic Arrays of Objects (Data Structures course, step-by-step)

Поделиться
HTML-код
  • Опубликовано: 23 янв 2025
  • НаукаНаука

Комментарии • 92

  • @CodeBeauty
    @CodeBeauty  Год назад +18

    📚 Learn programming with these Free E-Books ⬇
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    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 FROM THE VIDEO**
    #include
    using namespace std;
    class Student {
    public:
    string Name;
    int Age;
    char Gender;
    float ProgrammingGrade;
    };
    void printStudents(Student* students, int size) {
    for (int i = 0; i < size; i++) {
    cout

    • @awaism.a5192
      @awaism.a5192 Год назад

      Absolutely superb ❤ but i need to know about female and boys array how to do that could just show me declaring it how to declare it i dont get any idea to do it

  • @heikin5562
    @heikin5562 10 месяцев назад +5

    Thank you so much for this free lesson. I can finally finish my project about array insertion and deletion, with the knowledge i gained here

    • @CodeBeauty
      @CodeBeauty  9 месяцев назад

      Glad it was helpful!

  • @omercandemirci6410
    @omercandemirci6410 Год назад +5

    Thanks saldina for your helps. As an turkish electrical engineer student which want to learn Computer science, it is Hard to me learn something due to my language. Your language and explanation so clear that I can comprehend all what you want to teach in video. You are not just programmer teacher for me but also english teacher. ❤

    • @CodeBeauty
      @CodeBeauty  Год назад +2

      You're very welcome! I'm genuinely glad to hear that my explanations are helping you grasp the concepts. I'm here to support your learning journey in both computer science and English. Your dedication and enthusiasm are truly commendable. Keep up the great work, and don't hesitate to reach out if you have more questions or need further assistance. Happy learning! 🌟

  • @aaronsj80
    @aaronsj80 Год назад +6

    I like that you covered how the string is a pointer and also that you talked about the size of the student class. I noticed on the spreadsheet your addresses for each element were consecutive bytes, so it's good that you clarified it when getting to the copy code.

    • @CodeBeauty
      @CodeBeauty  Год назад +1

      I realized that using Excel would help students visualize what I'm explaining, and I'm glad that it was helpful. :D

  • @milkamilkica1935
    @milkamilkica1935 Год назад +3

    the best teacher ever!

  • @tumwesigyeisaac5073
    @tumwesigyeisaac5073 Год назад +2

    hi Saldina, am an electrical engineering student at Kabale university in Uganda.
    i love the way you deliver programming content, you really made me fall in love with programing though am pursuing electrical engineering

  • @874D8
    @874D8 9 месяцев назад +1

    the explanation about memcpy , deep and shallow copy was 🔥

  • @htvital4184
    @htvital4184 Год назад +4

    Thanks from bottom of my heart

  • @carmelostagno6352
    @carmelostagno6352 Год назад +2

    if the course you are preparing will be like these videos, then I can't wait. Thanks Saldina!

    • @CodeBeauty
      @CodeBeauty  Год назад +1

      It will be better! I put so much work and effort into the course. I'm sad that I can not finish it faster, but quality requires time, and this has to be the best programming course ever. Coding will become your native language after this course. Whatever you can think of, you can create with your own hands and a keyboard! ❤️

  • @rezafarokh8637
    @rezafarokh8637 Год назад +2

    34:43 Practical task for you (with instructions)
    Student* getInput(Student* students, int start, int end) {
    for (int i = start;i < end; i++) {
    cout > students[i].Age >>
    students[i].Gender >> students[i].ProgrammingGrade;
    cout

  • @AsakuraDantes
    @AsakuraDantes Год назад +4

    Thanks mommy, i have learned a lot ❤

  • @eliasrodriues6614
    @eliasrodriues6614 Год назад +3

    You are a good teacher.

  • @yuanmeng-q5i
    @yuanmeng-q5i Год назад +1

    Thanks a lot! I have learned much C++ skills from you, I love you CodeBeauty!

  • @lickguitars1276
    @lickguitars1276 Год назад

    Thank you for this concise tutorial on dynamic arrays! It made the concept much clearer for me, and im sure it will benefit others too

  • @handover007
    @handover007 8 месяцев назад +1

    I want to see more videos like this.
    Thanks Saldina.

    • @CodeBeauty
      @CodeBeauty  8 месяцев назад

      You're welcome 😊 🥰

  • @kamyarbasiri959
    @kamyarbasiri959 Год назад +2

    I'm looking forward watching the video

    • @CodeBeauty
      @CodeBeauty  Год назад

      let me know if you find it helpful :D

  • @Tableskater
    @Tableskater Год назад +1

    You are so awesome ❤❤❤😊😊

  • @MilesGerome
    @MilesGerome Год назад +1

    great job, thank you Saldina, this is very helpful

  • @zoldyck3526
    @zoldyck3526 Год назад +1

    Thanks a lot you are a good teacher.

  • @amelccc
    @amelccc Год назад +1

    great job as always 👌👌

  • @Sam-k1i2i
    @Sam-k1i2i Год назад +1

    great value, thank you Saldina

  • @codeoasis1180
    @codeoasis1180 Год назад +2

    great explanation

  • @MikeysLab
    @MikeysLab Год назад

    What is the efficency difference between changing student name to a fixed primitive (char Name[32]) and using memcpy, over doing a deep copy. The deep copy seems extremely inefficent especially in an embedded environment.

  • @shreyashpawar1689
    @shreyashpawar1689 Год назад +1

    Love from India ❤🇮🇳

  • @deanmorrison6254
    @deanmorrison6254 Год назад +1

    very helpful, thank you so much

  • @valjo02
    @valjo02 Год назад +2

    Would you provide pastebin of above code or we should put an efford and try rewrite in our IDE Saldina?

    • @CodeBeauty
      @CodeBeauty  Год назад +1

      Hey, I pinned the code in the first comment. :D

    • @valjo02
      @valjo02 Год назад +1

      Wow !I found it.Thanks a lot .Finally uderstand the main point of the code is to showcase how to dynamically allocate memory for an array of objects,
      resize the array based on user input, and copy the existing objects to the new array while adding new objects if required.
      👍👌💜@@CodeBeauty

  • @vetledeilkas538
    @vetledeilkas538 Год назад

    When the program exits, all memory (both on the stack and on the heap) is deallocated automatically. So to delete the memory right before the program exits makes no difference, although it is good practice!
    Also, with the practice example, there's no need to return a pointer to the array of students, as you pass the pointer to the students array as an argument to the function. Returning void is sufficient. The same array will be modified in the function as the memory of the array is passed to the function.
    Please correct me if I said something wrong! Overall very good video!

    • @CodeBeauty
      @CodeBeauty  Год назад +1

      In C++, memory management is more manual. You need to allocate and deallocate memory yourself. In some other languages like C# for example, memory management is more automated, especially for objects on the heap, thanks to the garbage collector, which automatically frees memory when objects are no longer needed. Stack memory in C# is managed similarly to C++, where it's automatically deallocated when the variable's scope ends. :D

    • @CodeBeauty
      @CodeBeauty  Год назад +1

      One thing that you can do is use smart pointers. They are a container/wrapper for a raw pointer. In modern C++ smart pointers are defined in the std namespace in the memory header file.
      One big advantage of smart pointers is that they are responsible for deleting the memory that they use, which means that they automatically deallocate the memory when they go out of scope. :D
      You can check out my video about smart pointers if you want to learn more about this, here: ruclips.net/video/e2LMAgoqY_k/видео.html

  • @TrueNRG
    @TrueNRG Год назад +3

    Симпотная барышня😊

  • @carlosalbertoavilapalacios5623
    @carlosalbertoavilapalacios5623 Год назад +1

    Hi Saldina. Thanks for this video. Do you know of any extension for plotting data in Visual Studio 2022, for example, plotting a data array of velocity versus time? Excuse me for the question that is off-topic from the video. Thanks for your time. Best regards

    • @CodeBeauty
      @CodeBeauty  Год назад

      I think that Microsoft Chart Controls could be of help to you. I'm sure you can find plenty of resources online regarding this topic. Hope that helps. Cheers.

  • @lpmc1182
    @lpmc1182 Год назад +1

    do you have any suggestion of projects that are job-ready and worth to be added on a cv in order to apply for jobs? I'm struggling in finding project ideas and can't come up with any on my own, and "to do list" type of projects I assume they aren't job ready

    • @CodeBeauty
      @CodeBeauty  Год назад

      Well, depending on your current skill set there are many suitable ideas. But since you are on channel that is mainly focused on C++ and C# so far and given the fact that you are looking for a job, I will assume that you don't have that much experience yet so here are some of the projects that should not be too complex to develop but still very useful as showcase of your capabilities as well as good practicing materials:
      Simple Console Calculator:
      Create a console application that performs basic arithmetic operations like addition, subtraction, multiplication, and division based on user input.
      Guess the Number Game:
      Develop a game where the computer generates a random number, and the player has to guess it within a certain number of tries.
      Library Management System:
      Design a program that allows users to manage a library's inventory, including adding, searching, and borrowing books.
      Student Grade Tracker:
      Build an application to store and calculate student grades. Allow users to input and retrieve student data and calculate averages.
      Personal Expense Tracker:
      Develop a program that helps users track their daily expenses and presents them in a clear and organized manner.
      Address Book:
      Build an application that allows users to store and manage contacts' information, including names, phone numbers, and addresses.
      Also, be sure to sign up here bit.ly/SimplifyingCoding
      and I will let you know when my practical programming course is out, with a nice discount attached. It will serve you greatly in your search for a job.
      Hope you will find these useful. Good luck with finding the right job for you! :)

  • @branriv8417
    @branriv8417 Год назад +1

    Hi Saldina. What program do you use to allow your viewers to see you and your screen simultaneously?

    • @CodeBeauty
      @CodeBeauty  Год назад

      I'm filming me with the camera, separately from screen, which is recorded with OBS studio, then in editing I'm combining it into one video. Hope that helps.

    • @branriv8417
      @branriv8417 Год назад

      @@CodeBeauty Thank you.

  • @jaykay6249
    @jaykay6249 Год назад

    Really helpful thanksksks

    • @jaykay6249
      @jaykay6249 Год назад

      You could maybe also provide the code you wrote so we could poke around a bit.

  • @nicholaskomsa1777
    @nicholaskomsa1777 8 месяцев назад

    there is some std STL object, std::array, which would be used in place of a depreciated sort of c-array

  • @AbderrahmenBenabbas
    @AbderrahmenBenabbas Год назад +2

    Could you give me the names of C++ Books that you have read

    • @CodeBeauty
      @CodeBeauty  Год назад

      check out these 2, they are free, and they are very good (one of them is for C++)
      bit.ly/freeCppE-Book
      bit.ly/FreeObjectPascalEbook

  • @christopherrice891
    @christopherrice891 Год назад +3

    Saldina have you ever made a 3-D open world video game in C++? I'm asking because making games is why i want to learn C++ so badly.

    • @CodeBeauty
      @CodeBeauty  Год назад +2

      I did my fair share of coding in gaming world as well and for sure I can see certain appeal in it. What are you mostly interested in?

    • @christopherrice891
      @christopherrice891 Год назад

      @@CodeBeauty i am mostly interested in games like on Playstation 5 or Game Cube or X-BOX. I watch the beginning stages of making a game on RUclips, but i never once saw a video game built from the ground up. I want to see a full game created.

  • @anwar6971
    @anwar6971 Год назад +1

    Thanks

  • @_-deep_a_b.862
    @_-deep_a_b.862 Год назад

    thanks!

  • @mthabisidlamini8168
    @mthabisidlamini8168 Месяц назад

    How do l acquire your certificate for software development in c++

  • @xamgodoix
    @xamgodoix Год назад

    Hi! I think there is something "wrong" with the example:
    Student *students = new Students[3];
    The expression above already allocate space for 3 students. There is no need to create another Student inside for loop.
    Inside for loop could be something like this:
    Student &s = students[i];
    A reference to each student already allocated.

    • @CodeBeauty
      @CodeBeauty  Год назад +1

      There are two options for adding data: you can create a new variable, allow the user to input data into it, and then insert this variable into the array. Alternatively, you can directly input the data into the array. It's a good exercise if someone wants to try and practice on his own. :D

  • @AlexFranck-sx7tc
    @AlexFranck-sx7tc Год назад

    21:13 that's not an advantage.
    you can very much define the size of a "static" array at runtime. The term "static array" is common but I do not understand its meaning. I would simpy call it arrays stored on the stack or stack arrays.
    so-called dynamic arrays are simply arrays created in the heap memory. I would call them heap arrays.
    the size of an array cannot be changed.
    I believe what you are trying to say is: data stored in a heap array can always be relocated to accommodate new data.
    the size of an array does not change. rather the data can be moved to a larger or smaller array, or simply to another array.

    • @CodeBeauty
      @CodeBeauty  Год назад

      If you have static array you cannot reallocate it to add more elements.
      The size that you define while you are writing the code is the size that array will have forever, and if your collection grows and you need to add more elements than the size of the array, you won't be able to store them. Also if you create very big static array, but big chunk of that memory is empty cuz you don't have elements to put into it, than you are simply wasting memory and memory management is not efficient.
      Because of that you can use dynamic arrays which can be deallocate and then you can allocate new (bigger, or smaller) space for them. That way your memory management is more efficient. :D

    • @AlexFranck-sx7tc
      @AlexFranck-sx7tc Год назад

      @@CodeBeauty you do not reallocate the array. you relocate the data. once you create an array, its size is final. it does not matter if you create it on the heap or on the stack.
      dynamic array is more like an umbrella term. when you get more data, you create a new heap array, you move the data to that new array, and release the memory areas occupied by the old array. the size of an array does not change. it never changes.

  • @muhmedgamal5841
    @muhmedgamal5841 7 месяцев назад

    goooooooooooooood

  • @nicholaskomsa1777
    @nicholaskomsa1777 8 месяцев назад

    actually, calling delete on a c style array is Undefined Behavior, not a memory leak.

  • @dattrax
    @dattrax Год назад

    I believe there was a technical error in this video. The reason for the delete is not correct, as without the [] it doesn’t run the destructors. This is where leaks occur, when the object contains another object, it wouldn’t get free’d. I also don’t believe it’s good practice to use naked new anymore but stl::vector would have been better in this instance.

    • @CodeBeauty
      @CodeBeauty  Год назад +1

      One thing that you can do is use smart pointers. They are a container/wrapper for a raw pointer. In modern C++ smart pointers are defined in the std namespace in the memory header file.
      One big advantage of smart pointers is that they are responsible for deleting the memory that they use, which means that they automatically deallocate the memory when they go out of scope. :D
      You can check out my video about smart pointers if you want to learn more about this, here: ruclips.net/video/e2LMAgoqY_k/видео.html
      And regarding memory leaks, try this tool. I believe it should be free to download it via this link and it is static code analyzer, so you run the analysis of your code and it wil tell you if there are memory leaks and even suggest how to fix them: bit.ly/PVS-StudioFreeCB1
      Hope this helps :D

  • @ross350tube
    @ross350tube Год назад

    or... You just use vectors, which have built functions that automatically manage much of this.

  • @nicholaskomsa1777
    @nicholaskomsa1777 8 месяцев назад

    dynamic array is literally std::vector with fewer features, depreciated

  • @deveshbhati8852
    @deveshbhati8852 Год назад +1

    Can we ?

    • @CodeBeauty
      @CodeBeauty  Год назад

      check your previous comment :)

  • @deveshbhati8852
    @deveshbhati8852 Год назад +2

    I am looking for connect with you

    • @CodeBeauty
      @CodeBeauty  Год назад

      here you can find links to my social media:
      linktr.ee/codebeautyprogramming?fbclid=PAAabr49GuzhYS4Jfh0vw7nyDk_-uqYqKhkauLq6cqyCQSGZUH5_dVDH6-41A
      Cheers. :)

    • @deveshbhati8852
      @deveshbhati8852 Год назад

      Can you please reply over Instagram ?

  • @Judgeman-f3q
    @Judgeman-f3q Месяц назад

    I wish she was mine

  • @robertbruce7686
    @robertbruce7686 Год назад +1

    Too many ju.....mp cuts

    • @CodeBeauty
      @CodeBeauty  Год назад +1

      you are missing the point of the video :D

  • @aapck
    @aapck Год назад

    In C++, the 'new' and 'delete' operators can be overridden, allowing us to execute our own code when allocating or deallocating memory. This is useful in situations where memory management is expected from you, such as in embedded systems where there is no operating system. In such cases, these operators are overridden.:o)

  • @YMX_750
    @YMX_750 Год назад

    void studentinfoin(Students* students,int start,int size){
    for(int i=start;i