blob: 03be16f6f8f5d54af31522ce02b6030232966c97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
}
|