【发布时间】:2022-01-02 06:46:06
【问题描述】:
所以我正在尝试解决以下任务:
下面是我想出的代码。我无法正确存储数据,我不确定将 read() 和 output() 函数放在哪里。这可能不是太难,但我仍然不确定。有人可以给我一个提示吗?谢谢!
#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;
}
【问题讨论】:
标签: c++ class memory dynamic c++14