Make Class Students, having
1. Private data items (First Name, Full Name, Address),
2. Public member functions, getData, showData.
3. Main () function
Create Array of objects (students), (maximum 5 students), call member functions
getData, showData const
#include <iostream>
#include <string>
using namespace std;
class Student
{
string FirstName;
string FullName;
string address;
public:
void getData()
{
cout << "Please, enter a First Name of student: ";
cin >> FirstName;
cout << "Please, enter a Full Name of student: ";
cin.ignore(256, '\n');
getline(cin, FullName);
cout << "Please, enter an address of student: ";
getline(cin, address);
}
void showData() const
{
cout << "\n\nInfo about student:";
cout << "\nFirst Name of student is " << FirstName;
cout << "\nFull Name of student is " << FullName;
cout << "\nAddress of student is " << address;
}
};
int main()
{
const int N = 3;
Student arrSt[N];
for (int i = 0; i < N; i++)
{
arrSt[i].getData();
}
for (int i = 0; i < N; i++)
{
arrSt[i].showData();
}
}
Comments
Leave a comment