Giter VIP home page Giter VIP logo

Comments (2)

SuyashD95 avatar SuyashD95 commented on July 17, 2024

Update 1:

Things that I have achieved in this update:

  1. Created a constructor which allocates the desired memory to the members using 'new' operator.
  2. Populated the members with data.

NOTE:
Even though I have uploaded this update, there are some areas/ concerns with this code that I want to draw your attention...

  • First, is the use of C-style arrays i.e, char arrays or char*... In modern C++, especially if you are using a C++ compiler based on C++11 or C++14 standard (or a later standard), it is highly recommended to use the std::string container to deal with string or multi-character based data...

  • Second, even though, I have used 'new' (since, it was mentioned in the question), I will also need to
    define a destructor to deallocate the memory that has been allocated to the members... But, again, this
    complicates the situation since the responsibility of dealing with releasing the memory and preventing
    situations like memory leaks fall on our shoulders...

    Hence, only use 'new' when it is absolutely necessary (or, in situations, when the question has
    explicitly mentioned to use it..) The program is working fine and it is terminating properly (hence, I feel
    that the code is freeing the memory properly, but again, be careful while using new and delete).

from cplusplus-prog-exercises.

SuyashD95 avatar SuyashD95 commented on July 17, 2024

Update 2:

The answer to this question is complete and hence, this issue is now 'closed'.

from cplusplus-prog-exercises.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.