Witam, napisałem taki kawałek programu:
#include <cstdlib>
#include <iostream>
#include <vector>
#include <string.h>
#include <conio.h>
using namespace std;
class HumanCL
{
public:
HumanCL() {}
virtual void Wyswietl()=0;
};
class MaleCL : public HumanCL
{
private:
string name;
string surname;
int plec; // 0- man, 1 female
int age; //wiek
int kids[10]; // max 10 dzieciakow mozna miec
int rodzic[2]; // 0 -> ojciec , 1 -> matka
int partner; // -1 = brak
public:
MaleCL(string name, string surname, int age);
void Wyswietl();
};
MaleCL::MaleCL(string name, string surname, int age) : HumanCL()
{
this->name=name;
this->surname=surname;
this->age=age;
plec=0;
}
void MaleCL::Wyswietl()
{
cout << "Plec: 'M'" << endl;
cout << "Imie: " << name << endl;
cout << "Nazwisko " << surname << endl;
cout << "Wiek: " << age << endl;
}
class FemaleCL : public HumanCL
{
private:
string name;
string surname;
int plec; // 0- man, 1 female
int age; //wiek
int kids[10]; // max 10 dzieciakow mozna miec
int rodzic[2]; // 0 -> ojciec , 1 -> matka
int partner; // -1 = brak
public:
FemaleCL(string name, string surname, int age);
void Wyswietl();
};
FemaleCL::FemaleCL(string name, string surname, int age) : HumanCL()
{
this->name=name;
this->surname=surname;
this->age=age;
plec=1;
};
void FemaleCL::Wyswietl()
{
cout << "Plec: 'F'" << endl;
cout << "Imie: " << name << endl;
cout << "Nazwisko " << surname << endl;
cout << "Wiek: " << age << endl;
}
/////////////////////////////GLOWNA KLASA FAMILY//////////////////////
class FamilyCL
{
private:
char plec;
string name, surname;
int age;
vector <HumanCL*> family;
public:
FamilyCL() {}
void AddPerson();
void Show();
};
void FamilyCL::Show()
{
for(int i=0; i < family.size(); i++)
{
cout << "Indeks: " << i+1 << endl;
family[i]->Wyswietl() << endl;
}
}
void FamilyCL::AddPerson()
{
cout << "Kogo chcesz dodac (M/F)?";
plec = getch();
cout << plec << endl;
cout << "Podaj imie: ";
cin >> name;
cout << "Podaj nazwisko: ";
cin >> surname;
cout << "Podaj wiek: ";
cin >> age;
if(plec == 'M' || plec == 'm')
family.push_back(new MaleCL(name, surname, age));
else
family.push_back(new FemaleCL(name, surname, age));
cout << "Osoba zostala dodana.\n";
}
int main()
{
FamilyCL obiekt;
obiekt.AddPerson();
obiekt.Show();
}
...i nie wiem czemu przy próbie wyświetlania danych z kontenera wyrzuca mi taki błąd:
void value not ignored as it ought to be
, a co gorsze, nie wiem jak się go pozbyć.