Witam, mam takie dwie klasy jak ponizej, ale mam w programie wykorzystac dziedziczenie,
wiec powtarzajace sie w obu klasach dwie zmienne "int Czas; double Kwota;" oraz dwie funkcje Jaka_Kwota(); i Jaki_Czas(); chcialbym dac to trzeciej class'y konto i uzyc w pozostalych klasach, czy jest taka mozliwosc, zeby funkcje wewnatrz classy Ror mogly korzystac z zmiennych class'y konto w ktorej beda zaimplementowane???
class Konta
{
private:
int Czas;
double Kwota;
public:
double Jaka_Kwota(void) {
return this->Kwota;
}
int Jaki_Czas(void) {
return this->Czas;
}
};
class Ror // : public Konta
{
int Czas;
double Kwota;
public:
Ror(double Kwota1, int Czas1)
{
this->Czas = Czas;
this->Kwota = Kwota;
};
~Ror() {};
double Jaka_Kwota(void) {
return this->Kwota;
}
int Jaki_Czas(void) {
return this->Czas;
}
};
class Lokata // : public konta
{
private:
TTimer *Zegar;
int Czas,Licznik,LicznikCzasu;
double Kwota,Oprocent;
public:
void __fastcall ZegarTimer(TObject *Sender)
{
Licznik+=1;
if(LicznikCzasu == Czas) {
Zegar->Enabled = false; return;
}
if(Licznik == 60) {
int Kwot = (Kwota * ((Oprocent/12.0)/100.0));
Kwota = Kwota + Kwot;
LicznikCzasu++;
Licznik = 0;
}
}
Lokata(double Kwota, int Czas)
{
this->Oprocent = Oprocentowanie(Czas);
this->Czas = Czas;
this->Kwota = Kwota;
this->Licznik = 0;
this->LicznikCzasu = 0;
Zegar = new TTimer(0);
Zegar ->OnTimer = ZegarTimer ; // Funkcja Timera
Zegar ->Interval = 1000 ; //1000 mili-sek == 1 sek
Zegar ->Enabled = true; // Uruchom timer
};
~Lokata()
{
Zegar->Destroying();
};
double Jaka_Kwota(void) {
return this->Kwota;
}
int Jaki_Czas(void) {
return this->Czas;
}
};