I am not able to add data on run time (dynamic allocation of memory) and then read that data and print all of the objects of class on screen!
can some one help please?
these are the functions i am using to store and display data!
Code:
void studentAdd() {
stds = new Students;
stds->Students::addStudent();
stds++;
}
void studentShow() {
int num=0;
int total = stds->Students::totalStds();
for (int i=0;i<total;i++) {
stds->Students::showStudent();
}
}
class member functions are!
Code:
void Students::addStudent() {
cout << "\n\n\tStudent ID:\t"<< stdId;
cout << "\n\tStudent Name:\t";
cin >> stdName;
cout << "\tStudent Age:\t";
cin >> stdAge;
cout << "\tStudent Class:\t";
cin >> stdClass;
cout << "\tTrnspt [1,0]:\t";
cin >> stdTransport;
cout << "\tHostel [1,0]:\t";
cin >> stdHostel;
stdExists=1;
}
void Students::showStudent() {
cout << "\n\n\tStudent ID:\t"<< stdId;
cout << "\n\tStudent Name:\t"<< stdName;
cout << "\n\tStudent Age:\t"<< stdAge;
cout << "\n\tStudent Class:\t"<< stdClass;
cout << "\n\tTrnspt [1,0]:\t"<< stdTransport;
cout << "\n\tHostel [1,0]:\t"<< stdHostel;
}