Witam, otóż mam utworzyć taką małą bazę danych przechowujacą dane studentów. Aczkolwiek główna część już jest gotowa, lecz pojawił się problem gdy po zapisaniu studenta chcę go wyświetlić na ekranie... Zorientowałem się iż program nie lokuje danych nigdzie i trzeba użyć tablic dynamicznych ale nie mam pojęcia jak je zastosować w moim programie, pomoże ktoś z tym?
#include <iostream>
#include <cstdlib>
using namespace std;
class Osoba{
protected:
string imie;
string nazwisko;
string telefon;
public:
void wyswietl(){
cout << "Imie: " << imie << endl;
cout << "Nazwisko: " << nazwisko << endl;
cout << "Numer tel.: " << telefon << endl;
}
Osoba(string i="imie",string n="nazwisko" , string t="numer telefonu")
{
imie=i;
nazwisko=n;
telefon=t;
}
};
class Student: public Osoba{
protected:
string semestr;
string kierunek;
string specjalnosc;
public:
void dodaj(){
cout << "Podaj imie: " << endl;
cin >> imie;
cout << "Podaj nazwisko:" << endl;
cin >> nazwisko;
cout << "Podaj numer telefonu" << endl;
cin >> telefon;
cout<< "Semestr: " << endl;
cin>> semestr;
cout<< "Kierunek: " << endl;
cin>> kierunek;
cout<< "Specjalnosc: " << endl;
cin >> specjalnosc;
}
void wyswietl(){
Osoba::wyswietl();
cout<< "Semestr: " << semestr << endl;
cout<< "Kierunek: " << kierunek << endl;
cout<< "Specjalnosc: " << specjalnosc << endl;
}
Student(string s="semestr", string k="?",string sp="?",string i="?",string n="?",string t="?")
:Osoba( i, n, t) //konstruktor
{
semestr = s;
kierunek= k;
specjalnosc = sp;
}
};
int main(){
int x;
do{
cout <<"***Program***"<< endl << endl;
cout <<"1.Dodaj Studenta" << endl;
cout <<"2.Edycja Rekordu" << endl;
cout <<"3.Wyswietl Studenta" << endl;
cout <<"4.Usuwanie Studenta" << endl;
cout <<"5.Koniec programu" << endl;
cin>> x;
switch(x){
case 1:
{
Student s1;
s1.dodaj();
break;
}
case 2:
{
break;
}
case 3:
{
Student s1;
s1.wyswietl();
break;
}
case 4:
{
break;
}
case 5:
exit(0);
default:
cout << "bye" << endl;
return 0;
}
}while(x!=0);
}