Cześć, powie mi ktoś dlaczego nie mogę utworzyć nowego obiektu dla klasy TOsoba?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
/*************************************************************************/
class adres///:public TOsoba
{
string miasto;
string ulica;
int numer;
public:
adres(string, string , int);
void Wyswietl();
};
adres::adres(string miasto,string ulica,int numer)
{
this->miasto=miasto;
this->ulica=ulica;
this->numer=numer;
}
void adres:: Wyswietl()
{
cout<<"miasto: "<<miasto<<"\nulica: "<<ulica<<"\nnr: "<<numer;
}
/************************************************************************************/
class TOsoba
{
protected:
string imie;
string nazwisko;
int wiek;
//adres xx;
public:
TOsoba(string,string,int);//,adres
void Wyswietl();
string PodajImie();
// string PodajNazwisko( return nazwisko;)
};
TOsoba::TOsoba(string i,string n, int w)//,adres x
{
this->imie=i;
this->nazwisko=n;
this->wiek=w;
//this->xx=x;
}
void TOsoba::Wyswietl()
{
cout<<"Imie: "<<imie<<"\nNazwisko: "<<nazwisko<<"\nWiek: "<<wiek;
}
string TOsoba::PodajImie()
{
return imie;
}
/*************************************************************************************/
main()
{
//adres a(Lubli,Kunickiego,22);
TOsoba (Jan,Kowalski,21)
//os1.PodajImie();
os1.Wyswietl();
return 0;
}