Question: #include #include #include DataStore.hpp /** * Construct an empty DataStore. */ DataStore::DataStore() { // TODO: Handle any default initialization you need here. } /** *

#include #include
#include "DataStore.hpp"
/** * Construct an empty DataStore. */ DataStore::DataStore() { // TODO: Handle any default initialization you need here. }
/** * Construct a DataStore that was saved to a file. * @param filename - name of file containing data to load. */ DataStore::DataStore(std::string filename) { // TODO: Read your output file into your program. // This cannot be done until you decide how you want to // format your file. }
/** * Destructor: cleanup any allocated memory. */ DataStore::~DataStore() { // TODO: Complete the destructor. // Note: you may remove this entirely (here and in .hpp) if your data is // stored entirely in automatic variables. }
Just the Constructor of both data store and the Destructor i need help with
#ifndef _DATA_STORE_HPP_ #define _DATA_STORE_HPP_
#include
public: /** * Construct an empty DataStore. */ DataStore();
/** * Construct a DataStore that was saved to a file. * @param filename - name of file containing data to load. */ DataStore(std::string filename); /** * Destructor: cleanup any allocated memory. */ ~DataStore(); /** * (disabled) Copy constructor -- create a new object as a copy of another. */ DataStore(const DataStore& other) = delete; /** * (disabled) Copy assignment -- copy another object into this object. */ DataStore& operator=(const DataStore& rhs) = delete; /** * (disabled) Move constructor -- create a new object with the data of another. */ DataStore(DataStore&& other) = delete; /** * (disabled) Move assignment -- move data from other object to this object. */ DataStore& operator=(DataStore&& rhs) = delete;
/** * Add a value to our storage. * @param value - The value to add. */ void add_value(const int& value);
/** * Remove a value from storage, if it exists. * @param value - The value to remove. * @return true if the value was successfully removed and * false otherwise. */ bool remove_value(const int& value);
/** * Get the number of entries for a particular value. * @param value - The value to count occurrences of. * @return The number of times the value was entered. */ int get_count(const int& value);
/** * Create a space separated string of stored data as a single line. */ std::string to_string();
/** * Write out the data stored to a file. * @param filename - The name of the file to write to. */ void write_out(std::string filename); };//DataStore
#endif
i guess with a vector to store the data,
Problem 2. (80 points) Your task is to build a system to store data as it is provided through a sequence of additions and removals. One feature of this system is to save the data to disk in order to load it at a later point in time. For your designed, you will have to implement the sepcified API in order to provide required functionality, but the internal storage and saved file format are left for you to decide. One thing to note is that you should aim to be efficient in your design To realize this system, you will need to complete the class definition for DataStore by completing the following method definitions . Constructor DataStore: :DataStore perform any default initialization necessary - Note: this is dependant on your implementation. If you are not using anything that needs allo- cation, then this will likely be left empty Constructor DataStore: :DataStore (std::string filename) - initialize the data store to the values stored in the file filename . Destructor DataStore::~DataStore ) - cleanup any allocated memory - Note: this is dependant on your implementation. If you are not using anything that needs deal location, then this will likely be left empty void DataStore::add value (const int&) -record the value in value into your data store - the same value may be added numerous times. bool DataStore:: remove_value (const int&value) - if the value was not previously added, return false, otherwise remove all records of the value in value from your data store and return true - E.g., the following code should print out the value 0: DataStore storage; atorage.add value (5) storage.add value (5) storage.add_ value (5) storage remove value (5) std::cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
