I am a beginner in programming by C ++. This is my first question on EE also.
I am learning the book of Bjarne Stroustrup "Programming. Principles and Practice Using C ++".
I'm using MS Visual Studio 2019 for creation of C ++ programs.
I am performing following exercise:
“Define an Order
class with (customer) name, address, data, and vector<Purchase>
is a class with a (product) name, unit_price
, and count
members. Define a mechanism for reading and writing Orders
to and from a file. Define a mechanism for printing Orders
. Create a file of at least ten Orders
, read it into a vector<Order>
, sort it by name (of customer), and write it back out to file. Create another file of at least ten Orders
of which about a third arc the same as in the first file, read it into a list<Order>
, sort it by address (of customer), and write it back out to file. Merge the two files into a third using std:: merge()
I wrote the program consisting of the following files:
Header file from B.Stroustrup
This file contains declarations of functions.
p , Date_definitions_file_.cpp
These files contain definitions of functions
This is a main file.
Input data are in this file. For an example, I took three objects
Result data are in this file
And at last problem:
Objects of class Order are stored In the File_input.txt file. As I wrote above, I placed three objects in this file. The code should copy all data from the File_input file into the File_output file. But the program copies the first two objects. The program does not copy the last (third) object.
Please, help to find a program error, and also as to correct it.
P.S: I checked all files before sending. The program is compiled and carried out.