passing structure to function in c++ example
#include <iostream>
using namespace std;
struct Employee {
int id;
string name;
double salary;
};
void displayEmployee(Employee emp) {
cout << "ID: " << emp.id << endl;
cout << "Name: " << emp.name << endl;
cout << "Salary: " << emp.salary << endl;
}
int main() {
Employee emp1 = {1, "John Doe", 50000.0};
displayEmployee(emp1);
return 0;
}