I have created two classes (Konto and Bank). I can access my first class (konto) through the main function but I can not access my second class (Bank) in order to set/change its values.
One of my friends told my that the problem is that I have my code in subfolders but I really do not know what it is and how I delete it.
So how can I access my second class(Bank) is my question.
#include <iostream>
#include <string>
#include <vector>
class Konto {
public:
int konto_nummer;
std::string agare;
double saldo;
double rantesats;
public:
Konto(int _nummer, std::string _agare, double _saldo, double _rantesats);
int ge_konto_nummer();
void ranteutbetalning(double r);
//~konto();
friend class Bank;
};
class Bank {
private:
std::vector<Konto> konton;
int antal_konton;
int bank();
public:
Bank(std::vector<Konto> _konton, int _antal_konton);
void skrivut();
//~Bank();
};
Bank::Bank(std::vector<Konto> _konton, int _antal_konton)
: konton{_konton}, antal_konton{_antal_konton} {}
Konto::Konto(int _nummer = 12345, std::string _agare = "Ali",
double _saldo = 500, double _rantesats = 0.07)
: konto_nummer{_nummer}, agare{_agare}, saldo{_saldo}, rantesats{
_rantesats} {}
int Konto::ge_konto_nummer() { return konto_nummer; }
void Konto::ranteutbetalning(double r = 0.07) {
rantesats = r;
saldo += (rantesats * saldo);
}
void Bank::skrivut() {
int choose;
std::cout << "Choose: " << std::endl;
std::cout << "1- Adda new account: " << std::endl;
std::cout << "2-Print ur accounts: " << std::endl;
std::cout << "3- Search for accounts: " << std::endl;
std::cout << "4-Avsluta" << std::endl;
std::cin >> choose;
}
int main() {
Konto person;
std::cout << "Account: " << person.konto_nummer << std::endl;
std::cout << "Owner: " << person.agare << std::endl;
std::cout << "saldo: " << person.saldo << std::endl;
std::cout << "Rantesats: " << person.rantesats << std::endl;
std::cout << "===============================" << std::endl;
Bank obj;
obj.skrivut();
}
Aucun commentaire:
Enregistrer un commentaire