Question

The code should be written in C++. I included the Class used for this function. Also,...

The code should be written in C++.
I included the Class used for this function. Also, please fix the main function if necessary.

Description: This function de-allocates all memory allocated to INV. This will be the last function to be called (automatically by the compiler)
//before the program is exited.

This function also erased all data in the data file. There are other functions that add, process and alter the file; the file printed after those functions will have new data. HOWEVER, this destructor function will delete all those data and the output file will become empty.

class order_record
{
public:
   string cell_number;
   string item_number;
   double quantity;
   double price;
   int processing_plant;
   double tax_rate;
   double order_tax;
   double net_cost;
   double total_cost;
};

class order_class
{
public:
   order_class();
   ~order_class();
   bool is_Empty();
   bool is_full();
   int search(const string key);
   void add();
   void remove(const string key);
   void double_size();
   void process();
   void print();
   int count;
   int size;
   order_record *INV;
};

order_class::~order_class()
{
    // Enter the Code here.
   cout << "The destructor has been called\n";
}

int main()
{

//Test 4:
   //destructor will be invoked when object myOrders goes out of scope
   cout << "Test 4: Destructor called" << endl;
   cout << "End of Test 4" << endl;
   cout << "**********************************************************************\n";
   cout << "**********************************************************************\n";

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

order_class::~order_class()

{

// Enter the Code here.

for(int i=0; i<count;i++){

remove(INV[i].cell_number);

}

delete(INV);

cout << "The destructor has been called\n";

}

Add a comment
Know the answer?
Add Answer to:
The code should be written in C++. I included the Class used for this function. Also,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help fix my code C++, I get 2 errors when running. The code should be...

    Please help fix my code C++, I get 2 errors when running. The code should be able to open this file: labdata.txt Pallet PAG PAG45982IB 737 4978 OAK Container AYF AYF23409AA 737 2209 LAS Container AAA AAA89023DL 737 5932 DFW Here is my code: #include <iostream> #include <string> #include <fstream> #include <vector> #include <cstdlib> #include <iomanip> using namespace std; const int MAXLOAD737 = 46000; const int MAXLOAD767 = 116000; class Cargo { protected: string uldtype; string abbreviation; string uldid; int...

  • C++ assignment help! The instructions are below, i included the main driver, i just need help...

    C++ assignment help! The instructions are below, i included the main driver, i just need help with calling the functions in the main function This assignment will access your skills using C++ strings and dynamic arrays. After completing this assignment you will be able to do the following: (1) allocate memory dynamically, (2) implement a default constructor, (3) insert and remove an item from an unsorted dynamic array of strings, (4) use the string class member functions, (5) implement a...

  • Design a class named Triangle that extends GeometricObject class. The class contains: Three double data fields...

    Design a class named Triangle that extends GeometricObject class. The class contains: Three double data fields named side1, side2, and side3 with default values 1.0 to denote three sides of the triangle. A no-arg constructor that creates a default triangle with color = "blue", filled = true. A constructor that creates a triangle with the specified side1, side2, side3 and color = "blue", filled = true. The accessor functions for all three data fields, named getSide1(), getSide2(), getSide3(). A function...

  • in c++ please include all of the following " template class, template function, singly linked list,...

    in c++ please include all of the following " template class, template function, singly linked list, the ADT stack, copy constructor, operator overloading, "try catch"and pointers Modify the code named "Stack using a Singly Linked List" to make the ADT Stack that is a template class has the code of the destructor in which each node is directly deleted without using any member function. As each node is deleted, the destructor displays the address of the node that is being...

  • soccerApp.cpp is used to test your code and contains the main function. No changes to this...

    soccerApp.cpp is used to test your code and contains the main function. No changes to this file are necessary. Inside of the soccerPlayer.cpp file, implement the three member functions that are specified in soccerPlayer.hpp. The member function definition for print is already provided. soccerPlayer.cpp: #include "soccerPlayer.hpp" void TopTwoPlayer::print() const { cout << left << setw(8) << "Name: " << setw(18) << name << setw(10) << "Country:" << setw(18) << country << setw(14) << "appearances:" << right << setw(3) << appearances...

  • Hi there, I am working on a binary search tree code in c++. The program must...

    Hi there, I am working on a binary search tree code in c++. The program must store and update students' academic records, each node includes the student name, credits attempted, credits earned and GPA. I have made some progress with the code and written most of the functions in the .cpp file (already did the .h file) but i am struggling with what to put in the main and how to put an update part in the insert function. I...

  • 10.18 LAB: Plant information (vector) Given a base Plant class and a derived Flower class, complete...

    10.18 LAB: Plant information (vector) Given a base Plant class and a derived Flower class, complete main() to create a vector called myGarden. The vector should be able to store objects that belong to the Plant class or the Flower class. Create a function called PrintVector(), that uses the PrintInfo() functions defined in the respective classes and prints each element in myGarden. The program should read plants or flowers from input (ending with -1), adding each Plant or Flower to...

  • USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds...

    USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds data about an item in a retail store. The class should have the following member variables: description: A string that holds a brief description of the item. unitsOnHand: An int that holds thw number of units currently in inventory. price: A double that holds that item's retail price. Write the following functions: -appropriate mutator functions -appropriate accessor functions - a default constructor that sets:...

  • Requirements I have already build a hpp file for the class architecture, and your job is to imple...

    Requirements I have already build a hpp file for the class architecture, and your job is to implement the specific functions. In order to prevent name conflicts, I have already declared a namespace for payment system. There will be some more details: // username should be a combination of letters and numbers and the length should be in [6,20] // correct: ["Alice1995", "Heart2you", "love2you", "5201314"] // incorrect: ["222@_@222", "12306", "abc12?"] std::string username; // password should be a combination of letters...

  • Introduction In this lab, you are supposed to implement a graph class with the data structure...

    Introduction In this lab, you are supposed to implement a graph class with the data structure implemented before like linked list and queue. graph The class graph contains three member variables: linkedList *adjacentVertices; //an array of linked list. For a vertice i, adjacentVertices[i] stores the linked list that contains all other vertices connected to vertice i. int numVertices; //The number of vertices in the graph. int maxNumVertices; //The maximum number of vertices the graph can hold. Following public methods are...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT