Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:09:45+00:00 2026-06-10T02:09:45+00:00

This is part of an assignment however I just asking for clarification: Load data

  • 0

This is part of an assignment however I just asking for clarification:

Load data from ATM.txt and store them in a dynamic array (ATM type,
not STL) when the program starts up.

How exactly do I do dynamic arrays without STL? I thought perhaps the assignment means using pointers, the “ATM Type” threw me off.

It’s mentioned again:

file accounts.txt into a dynamic array (Account type, not STL)

–not part of Assignment

I’ve never understood the use of memory unsafe operations, eg pulling the number of items in a file from the first line:

eg.

5
abc
def
hij
kml
mno

Wouldn’t it be smarter to use STL (vectors, or C++11 arrays) and not rely on the number in the file as it may not be accurate causing buffer overflows etc?

//Edit
Define a class Account in a file Account.h which contains the data members: customer
id, BSB number, etc.

I assume Account and ATM types are those classes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:09:46+00:00Added an answer on June 10, 2026 at 2:09 am

    The most basic form of dynamic array is one created using new[], and destroyed using delete[]:

    ATM * atms = new ATM[count];
    // do stuff with the array
    delete [] atms;
    

    However, this brings the danger that the code using the array might throw an exception, return from the function, or otherwise prevent the delete[] from happening. If that happens, then you will lose the only pointer to the allocated memory, and it will remain allocated but inaccessible; this is known as a memory leak. For this reason, it’s better to wrap the array in a class, with:

    • member variables to store a pointer to the array, and (optionally) its size
    • constructors and/or functions to allocate the array
    • a destructor to delete the array
    • (optionally) function(s) to resize the array

    Deleting the allocation in an object’s destructor uses the principle of RAII to ensure that the array is deleted once it is no longer needed.

    This leaves one more danger: if you copy this array object, then you will end up with two objects that both try to delete the same array, which is disasterous. To prevent this, you’ll need to consider the Rule of Three. Either write a copy constructor and copy-assignment operator to allocate a new array and copy the contents; or delete them. (If you’re learning old-fashioned C++, then you can’t delete member functions, so you’ll have to declare them private and not implement them instead).

    Wouldn’t it be smarter to use STL?

    Usually, yes. But if you’re learning C++, it’s a good idea to understand how memory management works, as well as how to get the library to handle it for you. That’s probably part of the point of this exercise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is part of a homework assignment. I've got several questions asking find the
This is for an assignment, however ive done a lot on my part to
(this is indirectly a part of a much larger homework assignment) I have something
I have this part of script from my GAE application which uses webapp2, which
Let me start by saying this is associated with a homework assignment. However, this
This was a 2 part assignment. first I had to figure out how to
I'm on the last part of this assignment any help would be greatful thank
This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] =
This part of my code is used to award a grade to a student
This part of an app that I am working on, I have the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.