ดังนั้นฉันกำลังพยายามแก้ปัญหาตามงาน:
ด้านล่างคือรหัสที่ฉันมาอยู่ด้วย ฉันมีปัญหาเรื่องการจัดเก็บข้อมูลอย่างถูกต้องและผมไม่แน่ใจว่าจะวางตรงไหนที่อ่าน()และส่งออกฟังก์ชัน(). นี่อาจจะไม่ใช่ทั้งหมดเป็นอย่างลำบากแต่ฉันยังไม่แน่ใจ ใครก็ได้อาจจะช่วยใบ้ให้ผมหน่อ? ขอบคุณ!
#include <iostream>
#include <iomanip>
using namespace std;
class Employee
{
public:
string name, department;
int age;
void output(string &a, int &b, string &c)
{
cout << name << endl;
cout << "Age: " << age << " years" << endl;
cout << "Department: " << department << endl;
}
void read(int &n)
{
cout << "Enter number, last name and first name:";
cin >> name;
cout << "Enter age:";
cin >> age;
cout << "Enter department:";
cin >> department;
}
};
int main() {
int n;
cout << "Enter number of employees: ";
cin >> n;
Employee* o = new Employee;
Employee employee;
delete o;
}