So id like to make a simply bank account in c++ with simple methods to add or withdraw money and check the current balance but it doesn't compile and i don't know why. Variables and methods are in german but it should be clear i hope.
konto.h:
#include <stdio.h>
#include <string>
class Konto
{
public:
Konto();
~Konto();
void einzahlen(float geld);
void abheben(float geld);
float kontostand();
float balance;
};
konto.cpp
#include "konto.h"
Konto::Konto()
{
balance = 0;
}
Konto::~Konto()
{
}
void Konto::einzahlen(float geld)
{
balance += geld;
}
void Konto::abheben(float geld)
{
balance -= geld;
}
float Konto::kontostand()
{
return balance;
}
main.cpp
#include "konto.h"
void getKontostand(Konto k)
{
printf("Aktueller Kontostand: %f⁄n", k.kontostand());
}
int main()
{
Konto k(0);
k.einzahlen(1000);
k.abheben(400);
k.abheben(400);
getKontostand(k);
}