Complete the following program with appropriate C++ statements in order to write an object data into a binary file (just drag and drop the given C++ statements into the correct place). 1 #include #include <| > 3 4 class Person

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 5PP: (Data processing) Write a C++ program that reads the file created in Exercise 4, permits the user to...
icon
Related questions
Question
100%

DATA STRUCTURE AND ALGORITHM

Complete the following program with appropriate C++ statements in order to write an object
data into a binary file (just drag and drop the given C++ statements into the correct place).
1
#include <iostream>
#include <|
>
3
4
class Person
5
{
6.
private:
7
int id;
8
char name[50];
10
public:
11
Person(int n, const char *s);
12
13
void save
& of);
14
|};
15
16
int main()
17
{
18
Person me(8888, "Lizawati");
19
fstream myfile;
20
21
myfile.
("file.dat", ios::binary|
);
22
23
me.save (myfile);
24
myfile.
();
25
return 0;
26
27
28
void Person::save(
& of)
29
30
{
of.
(&id, sizeof(id));
of.
(name, sizeof(name));
}
fstream
read
close
ofstream
ios::out
ifstream
write
ios:in
open
Transcribed Image Text:Complete the following program with appropriate C++ statements in order to write an object data into a binary file (just drag and drop the given C++ statements into the correct place). 1 #include <iostream> #include <| > 3 4 class Person 5 { 6. private: 7 int id; 8 char name[50]; 10 public: 11 Person(int n, const char *s); 12 13 void save & of); 14 |}; 15 16 int main() 17 { 18 Person me(8888, "Lizawati"); 19 fstream myfile; 20 21 myfile. ("file.dat", ios::binary| ); 22 23 me.save (myfile); 24 myfile. (); 25 return 0; 26 27 28 void Person::save( & of) 29 30 { of. (&id, sizeof(id)); of. (name, sizeof(name)); } fstream read close ofstream ios::out ifstream write ios:in open
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
User Defined DataType
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr