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

Поділитися
Вставка

КОМЕНТАРІ • 90

  • @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 10 місяців тому

      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 7 місяців тому +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  6 місяців тому

      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

  • @htvital4184
    @htvital4184 Рік тому +4

    Thanks from bottom of my heart

  • @tumwesigyeisaac5073
    @tumwesigyeisaac5073 11 місяців тому +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

  • @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! ❤️

  • @874D8
    @874D8 6 місяців тому +1

    the explanation about memcpy , deep and shallow copy was 🔥

  • @handover007
    @handover007 4 місяці тому +1

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

    • @CodeBeauty
      @CodeBeauty  4 місяці тому

      You're welcome 😊 🥰

  • @milkamilkica1935
    @milkamilkica1935 Рік тому +3

    the best teacher ever!

  • @AsakuraDantes
    @AsakuraDantes Рік тому +4

    Thanks mommy, i have learned a lot ❤

  • @eliasrodriues6614
    @eliasrodriues6614 Рік тому +3

    You are a good teacher.

  • @TrueNRG
    @TrueNRG Рік тому +3

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

  • @codeoasis1180
    @codeoasis1180 Рік тому +2

    great explanation

  • @kamyarbasiri959
    @kamyarbasiri959 Рік тому +2

    I'm looking forward watching the video

    • @CodeBeauty
      @CodeBeauty  Рік тому

      let me know if you find it helpful :D

  • @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

  • @yuanmeng-q5i
    @yuanmeng-q5i Рік тому +1

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

  • @shreyashpawar1689
    @shreyashpawar1689 Рік тому +1

    Love from India ❤🇮🇳

  • @zoldyck3526
    @zoldyck3526 Рік тому +1

    Thanks a lot you are a good teacher.

  • @MikeysLab
    @MikeysLab 8 місяців тому

    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.

  • @nicholaskomsa1777
    @nicholaskomsa1777 5 місяців тому

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

  • @Tableskater
    @Tableskater Рік тому +1

    You are so awesome ❤❤❤😊😊

  • @Sam-k1i2i
    @Sam-k1i2i Рік тому +1

    great value, thank you Saldina

  • @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

  • @MilesGerome
    @MilesGerome Рік тому +1

    great job, thank you Saldina, this is very helpful

  • @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  Рік тому

      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: ua-cam.com/video/e2LMAgoqY_k/v-deo.html

  • @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

  • @deanmorrison6254
    @deanmorrison6254 Рік тому +1

    very helpful, thank you so much

  • @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 UA-cam, but i never once saw a video game built from the ground up. I want to see a full game created.

  • @_-deep_a_b.862
    @_-deep_a_b.862 10 місяців тому

    thanks!

  • @amelccc
    @amelccc Рік тому +1

    great job as always 👌👌

  • @carlosalbertoavilapalacios5623

    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.

  • @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.

  • @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! :)

  • @anwar6971
    @anwar6971 Рік тому +1

    Thanks

  • @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

  • @muhmedgamal5841
    @muhmedgamal5841 3 місяці тому

    goooooooooooooood

  • @nicholaskomsa1777
    @nicholaskomsa1777 5 місяців тому

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

  • @jaykay6249
    @jaykay6249 Рік тому

    Really helpful thanksksks

    • @jaykay6249
      @jaykay6249 Рік тому

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

  • @deveshbhati8852
    @deveshbhati8852 Рік тому +1

    Can we ?

    • @CodeBeauty
      @CodeBeauty  Рік тому

      check your previous comment :)

  • @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: ua-cam.com/video/e2LMAgoqY_k/v-deo.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

  • @nicholaskomsa1777
    @nicholaskomsa1777 5 місяців тому

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

  • @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.

  • @ross350tube
    @ross350tube Рік тому

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

  • @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 ?

  • @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 8 місяців тому

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