Hi, I study C++ myself and can't solve a little problem.
I created class konto (account) and it works fine. Now I want to create a class bank which contains several accounts and it should be possible to add a new account and to find a necessary account by number. I am not sure with all these arrays, how to do a class that contains several accounts from another class. I will appreciate smbs help. Please excuse my poor English. Thank you in advance.
# include <iostream.h>
# include <string.h>
class konto
{
public:
konto (char*,int,double,float);
void skrivut(void);
void insat(const int &i);
void uttag(float u);
void ranteutbet();
private:
int nomer;
char name[89];
double saldo;
float renta;
};
konto::konto(char* name,int nomer, double saldo, float renta)
{
strcpy (konto::name,name);
konto::nomer=nomer;
konto::saldo=saldo;
konto::renta=renta;
}
void konto::skrivut(void)
{
cout<<"name: "<<name<<endl;
cout<<"nomer: "<<nomer<<endl;
cout<<"renta%: "<<renta<<endl;
cout<<"saldo: "<<saldo<<endl<<endl;
}
void konto::insat(const int &i)
{
saldo=saldo+i;
}
void konto::uttag(float u)
{
saldo=saldo-u;
}
void konto::ranteutbet()
{
saldo=saldo+(saldo*2.5/100);
}
class bank
{
};
void main()
{
konto k ("Namn", 1, 1500, 2.5);
k.skrivut();
k.insat(500);
k.skrivut();
k.uttag(300);
k.skrivut();
k.ranteutbet();
k.skrivut();
}