Answer to Question #318352 in C++ for Muhammad Usman

Question #318352

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

1
Expert's answer
2022-03-26T08:42:47-0400
#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();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog