Write a program to order and print some tagged words

Assignment Help Computer Engineering
Reference no: EM131917188

Assignment

Purpose

The purpose of this assignment is to give you some experience with STL sets and operator overloading.

Assignment

Write a program to order and print some tagged words.

Program

The program is invoked with a command line argument giving the name of a data file.

The format of the data file is a list of pieces of data. Each piece of data is an integer followed by a string containing a single word. The words have no spaces in them. You should write a class to contain a single piece of data. The data members should be an integer and a string and should be private. The class will have several public methods.

Constructors

The class should have a default constructor. The class should also have a constructor that takes anint and astringand does the proper initialization. If you wish to use default arguments, it is possible to implement one constructor that takes care of both of these requirements.
operator []

Overload the subscripting operator. The method should always provide access to the string data member. Nothing more. The subscripting index will be unused, which means that this design is somewhat broken, but that's OK. This method serves as an accessor method for the string data member. No other accessor methods should be created for the final version of the class.

operator

Overload the less than operator to compare two instances of the class. This is critical for the functioning of the assignment. The class instances are compared by comparing their integer data members. The string data members are not used.

operator

Overload the output operator. This method should print the string data member of class to the output stream provided.

main()

Themain function should be placed in the fileassign4.cc. Themain() function for this assignment should take a command line argument, the name of the data file containing the data records. This argument will be found in argv[1]. If the number of arguments is wrong, the program should print a brief error message and exit.

The main() function should contain a set of the class created for holding individual data items.

The filename given on the command line should be opened as a file stream for input. If the file can't be opened, the program should print an error message and exit.

The program should read records from the file into the set. The set should be filled until there is no more data in the file. After reading, the file stream should then be closed.

The elements of the set should then be printed. The elements should be printed with a space between them.

There is one data value that must be treated differently for printing. If the data value is equal to the string "\n", then a new line should be printed rather than the string "\n"

Input

No additional information is needed here.

Output

The output will not be given here. When you get it right, you'll see a nicely formatted quote.

Implementation Hints

getline() can be used to input the data if you wish, but in the instructor's opinion, that makes it harder than it needs to be.Other Points

• Of course you should have a Makefile. Why are you still asking?
• The name of your executable should be assign4.
• The class should be implemented in its own source and header files.
• Submit your program using the electronic submission guidelines.

Reference no: EM131917188

Questions Cloud

Hedge exposure using futures contract : Suppose you operate a large gold distributor that sells gold to jewelry manufacturers nationwide. You wish to hedge this exposure using futures contract.
Draw a pareto diagram to analyze the defects : The following shows different types of warranty claims in the service department of a computer electronics chain. Draw a Pareto diagram to analyze the defects
Potassium hydroxide solution : A 34.6 mL sample of a 0.441 M aqueous hydrofluoric acid solution is titrated with a 0.397 M aqueous potassium hydroxide solution.
Time value of stock option increases with : Time value of a stock option increases with. An American call option gives the buyer the right to ________.
Write a program to order and print some tagged words : Write a program to order and print some tagged words. The program is invoked with a command line argument giving the name of a data file.
Concentration in a saturated solution of cobalt : The Co2+ concentration in a saturated solution of cobalt(II) hydroxide is measured and found to be 3.86×10-6 M.
Differences between workstation and server software : What are the differences between workstation software and server software? Windows workstations all have elements of server software built-in.
Create an erd that represents the entities and attributes : Create an ERD that represents the entities, attributes, the relationships between entities, and the cardinality and optionality of each relationship.
Analyse the movement of the aud relative to that of the usd : ECON910 - Using a Demand and Supply model of exchange rate determination, briefly explain how the exchange rate of the AUD is determined in the forex market

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd