I'm relatively new to C++. I'm using a function to give an object some values, but I keep getting the error that the object is being used without being initialized. How come?
The definition of Worker
:
class Worker
public:
int telephone;
char firstname[20];
char task[100];
int salary;
int id;
};
The actual code:
Worker worker1;
worker1 = getWorker(worker1);
Worker getWorker(Worker worker){
cout << "First name: ";
cin >> worker.firstname;
return worker;