Question

C++ PRPGRAM- double-linked lists Create the .h and .cpp files for an Element class that contains...

C++ PRPGRAM- double-linked lists

Create the .h and .cpp files for an Element class that contains the data and pointers for a double-link list for this application. Your linked list must consist of objects of this class. The class should contain at least the following elements (you may have more if you wish):

  • The standard four constructors (default, parameterized, copy, move)
  • The standard assignment operators (copy, move)
  • A destructor
  • Stream operators (<< and >>)
  • The standard relational operators (<, <=, ==, !=, >=, >)
  • Accessor for all instance variables
  • Mutators for all instance variables

The instance variables must be pointers, and they must be private.

Create the .h and .cpp files for a List class that implements the List ADT for objects of the Element class in a double-linked list. The List class must contain at least the following elements (you may have more if you wish):

  • The standard four constructors (default, parameterized, copy, move)
  • The standard assignment operators (copy, move)
  • A destructor
  • Stream operators (<< and >>)
  • The standard seven relational operators
  • Accessor for all instance variables
  • Mutators for all instance variables
  • Insert a new element into the list by position. This method can be used for general insertion, as well as push and append operations.
  • Remove an element by position. This method can be used for general removal, as well as pop and trim operations.

The instance variables must be pointers, and they must be private.

create main.h and main.cpp source code files that contains the C++ source code for a program that

  1. Accepts an input file name from the user
  2. If the input file can not be opened, display an appropriate message and end the program.
  3. Create a list of the words that appear in the file, along with the number of times each word appears. Each list element must be an object of the Element class, and the list must be an object of the List class. All list operations must be done using the standard class operators, accessors, mutators, and constructors. Your list should not have any duplicate words. There is no need to display the list in any particular order (no need to sort the list).
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Getting the file from the user


using namespace std;

int main() {
   string filename = "abc.txt";

   // Write to File

   ofstream fout(filename.c_str());
   if (!fout) {
      cerr << "error: open file for output failed!" << endl;
      abort();
   }
   fout << "apple" << endl;
   fout << "orange" << endl;
   fout << "banana" << endl;
   fout.close();

   // Read from file

   ifstream fin(filename.c_str());
   if (!fin) {
      cerr << "error: open file for input failed!" << endl;
      abort();
   }
   char ch;
   while (fin.get(ch)) { // till end-of-file
      cout << ch;
   }
   fin.close();
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
C++ PRPGRAM- double-linked lists Create the .h and .cpp files for an Element class that contains...
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
  • 1a. Create a class named Computer - Separate declaration from implementation (i.e. Header and CPP files)...

    1a. Create a class named Computer - Separate declaration from implementation (i.e. Header and CPP files) 1b. Add the following private member variables - an int variable named year - a string variable named model - a string variable named purpose 1c Add the following public functions: - Default constructor which sets numeric members to -1 and string members to the empty string - Destructor to print "Removing instance from memory" - A non-default constructor to set the year and...

  • 1a. Create a class named Inventory - Separate declaration from implementation (i.e. Header and CPP files)...

    1a. Create a class named Inventory - Separate declaration from implementation (i.e. Header and CPP files) 1b. Add the following private member variables - a int variable named itemNumber - an int variable named quantity - a double variable named cost - a double variable named totalCost. Total cost is defined as quantity X cost. - updateTotalCost() which takes no arguments and sets the values of the variable totalCost. 1c. Add the following public functions: - Accessor and Mutators for...

  • Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 files header file , one .cpp file for function and one more main cpp file) Operator...

    Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 files header file , one .cpp file for function and one more main cpp file) Operator Overloading – Chapter 14 Design a class Complex for representing complex numbers and the write overloaded operators for adding, subtracting, multiplying and dividing 2 complex numbers. Also create a function that will print a complex number on the screen. Provide appropriate constructors...

  • Create a cpp file that contains a constructor and destructor of a node in a circular...

    Create a cpp file that contains a constructor and destructor of a node in a circular doubly-linked list using the following header file: class CDLLNode { private: // these will contain the timestamp and content of the tweet as strings std::string time; std::string tweet; // these are pointers to the next and previous nodes in the CDLL CDLLNode *next; CDLLNode *prev; public: CDLLNode(const char *ti, const char *tw); ~CDLLNode(); friend class CDLL; };

  • Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 file...

    Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 files header file , one .cpp file for function and one more main cpp file) Operator Overloading – Chapter 14 Design a class Complex for representing complex numbers and the write overloaded operators for adding, subtracting, multiplying and dividing 2 complex numbers. Also create a function that will print a complex number on the screen. Provide appropriate constructors...

  • Part (A) Note: This class must be created in a separate cpp file Create a class...

    Part (A) Note: This class must be created in a separate cpp file Create a class Employee with the following attributes and operations: Attributes (Data members): i. An array to store the employee name. The length of this array is 256 bytes. ii. An array to store the company name. The length of this array is 256 bytes. iii. An array to store the department name. The length of this array is 256 bytes. iv. An unsigned integer to store...

  • Create a class called Retangle.java that contains two double-precision instance variables named width and height. The...

    Create a class called Retangle.java that contains two double-precision instance variables named width and height. The class should include all kinds of overloaded constructors. Additionally, there should be two accessor methods, mutator methods, class method named area() that returns the area of a Rectangle object. Inside main(),fully test all methods.

  • in C++, please help. Not only do we need to create an ADT but create a...

    in C++, please help. Not only do we need to create an ADT but create a main file as well to implement everything. For this program you will be creating a stack ADT to allow the client program to pick up treasures for a Star Wars scavenger game to get everyone ready for the opening of Galaxy’s Edge in 2020. Each treasure should have a (a) name, (b) description, (c) category, (d) what it is used for, and (e)if this...

  • Need help to create general class Classes Data Element - Ticket Create an abstract class called...

    Need help to create general class Classes Data Element - Ticket Create an abstract class called Ticket with: two abstract methods called calculateTicketPrice which returns a double and getld0 which returns an int instance variables (one of them is an object of the enumerated type Format) which are common to all the subclasses of Ticket toString method, getters and setters and at least 2 constructors, one of the constructors must be the default (no-arg) constructor. . Data Element - subclasses...

  • Design a class that contains: we have to make 3 files header file , one .cpp...

    Design a class that contains: we have to make 3 files header file , one .cpp file for function and one more main cpp file 9.3 (The Account class) Design a class named Account that contains: An int data field named id for the account. A double data field named balance for the account. A double data field named annualInterestRate that stores the current interest rate. A no-arg constructor that creates a default account with id 0, balance 0, and...

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