What is an Array of Objects in C++?
#include <iostream.h> const int MAX =100; class Details { private: int salary; float roll; public: void getname( ) { cout << "\n Enter the Salary:"; cin >> salary; cout << "\n Enter the roll:"; cin >> roll; } void putname( ) { cout << "Employees" << salary << "and roll is" << roll << '\n'; } }; void main() { Details det[MAX]; int n=0; char ans; do{ cout << "Enter the Employee Number::" << n+1; det[n++].getname; cout << "Enter another (y/n)?: " ; cin >> ans; } while ( ans != 'n' ); for (int j=0; j<n; j++) { cout << "\nEmployee Number is:: " << j+1; det[j].putname( ); } } |