From 2f1ad9ec273a0ff9e746e9f6c4cac2ce81cb31e4 Mon Sep 17 00:00:00 2001 From: Oskar Date: Thu, 3 Oct 2024 12:20:34 +0200 Subject: small test to play around abit with classes --- 7p57.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 7p57.cpp (limited to '7p57.cpp') diff --git a/7p57.cpp b/7p57.cpp new file mode 100644 index 0000000..03be16f --- /dev/null +++ b/7p57.cpp @@ -0,0 +1,39 @@ +#include + +/* + * + * 7.57 + * + * + */ + +class Account { +public: + Account(std::string o, double am): owner(o), amount(am) {} + Account(std::string o): Account(o, 0) {} + Account(): Account("John Doe", 0) {} + void calculate() { amount += amount * interestRate; } + static double rate() { return interestRate; } + static void rate(double); +private: + std::string owner; + double amount; + static double interestRate; + static double initRate(); +}; + +double Account::initRate() { + + return 1; +} + +double Account::interestRate = Account::initRate(); + +int main () { + + Account a1; + Account a2("Joe Johnsson"); + Account a3("Manny Manson", 1000); + std::cout << Account::rate() << std::endl; + return 0; +} -- cgit v1.2.3