👍 g++ database.cpp && ./a.out
1. Add 2. Find 3. Modify a rec 4. Exit
Enter an option: 1
Enter an option: 4
👍 cat database.h
#ifndef DATABASE
#define DATABASE
class Database {
public:
Database();
void run();
};
#endif
👍 cat database.cpp
#include <iostream>
#include "database.h"
using namespace std;
Database::Database() {
}
void Database::run() {
char option[5];
cout << "1. Add "
<< "2. Find "
<< "3. Modify a record "
<< "4. Exit\n";
cout << "Enter an option: ";
while (cin.getline(option, 4)) {
if (*option == '1') {
} else if (*option == '2') {
} else if (*option == '3') {
} else if (*option != '4')
cout << "Wrong option\n";
else return;
cout << "Enter an option: ";
}
}
int main() {
Database().run();
}
ch 1.10 CASE STUDY: RANDOM ACCESS FILE p43 of