this is the code for program in which using public static data member the information of 4 students is entered, means i have created 4 objects of class student. my program works but i want to modify my program in such a way i dont want to declare 4 objects separately kindly guide me, is there any way that i declare my object as array of objects so i reduce my code and not declaring objects in a line.
Code:
# include <iostream>
# include <conio.h>
using namespace std;
class student {
private:
char name[50];
char blood_group[15];
public:
void get_info ()
{
cout<<"enter name of student: ";
cin.getline (name,50);
cout<<"enter blood group of student: ";
cin.getline (blood_group,15);
}//end function
void show_info ()
{
cout<<"name is: "<<name<<endl;
cout<<"blood group is: "<<blood_group<<endl;
cout<<"roll number is: "<<++roll_num<<endl;
}//end function
};//end class
int student::roll_num=0;
int main ()
{
student s1,s2,s3,s4;
s1.get_info ();
s2.get_info();
s3.get_info();
s4.get_info();
s1.show_info ();
s2.show_info();
s3.show_info();
s4.show_info();
getch ();
}//end main