1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include <iostream>
#include <string>
using namespace std;
struct Person
{
string m_n; //name
string m_g; //birth-date
string m_gr;//height
string m_l; //age
static const string gr;
static const string g;
static const string l;
Person(const char * n_, const char * g_, const char * gr_, const char * l_):
m_n(n_),m_g(g_),m_gr(gr_),m_l(l_){}
};
const string Person::gr = "Grootte: ";
const string Person::g = "Geboortedatum: ";
const string Person::l = "Leeftijd: ";
ostream & operator<<(ostream & os, const Person & p)
{
os << Person::g << p.m_g << endl;
os << Person::gr << p.m_gr << endl;
os << Person::l << p.m_l << endl;
return os;
}
const int db_size=5;
Person database[]={
Person("Xander","26 september 1995","152 cm","15"),
Person("Dieter","27 juli 1997","146 cm","13"),
Person("Vincent","30 mei 2000","140 cm","10"),
Person("Erwin","3 november 1967","170 cm","42"),
Person("Els","7 oktober 1967","167 cm","42")
};
int main ()
{
int i;
cout<<"Welke persoon zijn details wil je?\nEnter zijn ID nummer\n";
cout<<"ID Naam\n\n";
for (i=0; i<db_size; i++)
cout << i+1 << ' ' << database[i].m_n << endl;
cin >> i;
cin.get();
cout << endl;
if (i>=1 && i<=db_size)
cout << database[i-1] << endl;
cout << "hit enter to quit...";
cin.get();
return 0;
}
|