1. In C ++, parameters can be passed to a function either by pointers or by references.
Here it was subsequently requested to implement the parameter transfer via pointer.
In C, Pass-by-reference is simulated by passing the address of a variable.
This is referred to as "C style pass-by-reference. (Source: www-cs-students.stanford.edu)
2. The questioner wants a solution with a structure instead of a class.
Unfortunately, the result is not good C ++ code, but rather a mixture of C ++ and old C code.
So here is the result:
typedef struct {
string name, location, manager_name;
int bank_id, emp_numbers;
} Bankinfo;
void getBankinfo(Bankinfo* b)
{
cout << "Name: ";
getline(cin, b->name);
cout << "Location: ";
getline(cin, b->location);
cout << "Manager-Name: ";
getline(cin, b->manager_name);
cout << "Bank ID: ";
cin >> b->bank_id;
cout << "Employees-Number: ";
cin >> b->emp_numbers;
}
void displayBankinfo(const Bankinfo *b) {
cout << b->name << endl;
cout << b->location << endl;
cout << b->manager_name << endl;
cout << b->bank_id << endl;
cout << b->emp_numbers << endl;
}
int main()
{
Bankinfo b;
getBankinfo(&b);
cout << "-------------------------------\n";
displayBankinfo(&b);
return 0;
}