diff options
author | Oskar <[email protected]> | 2024-10-03 12:20:34 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-10-03 12:20:34 +0200 |
commit | 2f1ad9ec273a0ff9e746e9f6c4cac2ce81cb31e4 (patch) | |
tree | a397e770261ea84eedbea851fd051210246f4a10 /7p57.cpp | |
parent | 3edb35c6cab27d36f0fde49726db8cc9289e7304 (diff) |
small test to play around abit with classes
Diffstat (limited to '7p57.cpp')
-rw-r--r-- | 7p57.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
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 <iostream> + +/* + * + * 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; +} |