*.cpp *.h: vim settings for 2-spaces instead of tabs
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
06b00b9f97
commit
768916ff0d
3 changed files with 39 additions and 34 deletions
12
account.cpp
12
account.cpp
|
@ -1,24 +1,24 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "account.h"
|
#include "account.h"
|
||||||
|
|
||||||
Account::Account ( double initial_balance ) : balance(initial_balance) {
|
Account::Account ( double initial_balance ) : balance(initial_balance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Account::~Account () {
|
Account::~Account () {
|
||||||
cout << "account deleted" << endl;
|
std::cout << "account deleted" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Account::getBalance() const {
|
double Account::getBalance() const {
|
||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::deposit(double amount) {
|
void Account::deposit(double amount) {
|
||||||
balance += amount;
|
balance += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::withdraw(double amount) {
|
void Account::withdraw(double amount) {
|
||||||
balance -= amount;
|
balance -= amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vim:set sts=2 sw=2 et:
|
||||||
|
|
40
account.h
40
account.h
|
@ -9,36 +9,38 @@
|
||||||
*/
|
*/
|
||||||
class Account
|
class Account
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* ==================== LIFECYCLE ======================================= */
|
/* ==================== LIFECYCLE ======================================= */
|
||||||
//Account (); /* constructor */
|
//Account (); /* constructor */
|
||||||
//Account ( const Account &other ); /* copy constructor */
|
//Account ( const Account &other ); /* copy constructor */
|
||||||
Account ( double initial_balance );
|
Account ( double initial_balance );
|
||||||
~Account (); /* destructor */
|
~Account (); /* destructor */
|
||||||
|
|
||||||
/* ==================== ACCESSORS ======================================= */
|
/* ==================== ACCESSORS ======================================= */
|
||||||
|
|
||||||
// current balance of the Account
|
// current balance of the Account
|
||||||
double getBalance() const;
|
double getBalance() const;
|
||||||
|
|
||||||
/* ==================== MUTATORS ======================================= */
|
/* ==================== MUTATORS ======================================= */
|
||||||
|
|
||||||
void deposit(double amount);
|
void deposit(double amount);
|
||||||
void withdraw(double amount);
|
void withdraw(double amount);
|
||||||
|
|
||||||
/* ==================== OPERATORS ======================================= */
|
/* ==================== OPERATORS ======================================= */
|
||||||
|
|
||||||
Account& operator = ( const Account &other ); /* assignment operator */
|
Account& operator = ( const Account &other ); /* assignment operator */
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* ==================== DATA MEMBERS ======================================= */
|
/* ==================== DATA MEMBERS ======================================= */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* ==================== DATA MEMBERS ======================================= */
|
/* ==================== DATA MEMBERS ======================================= */
|
||||||
|
|
||||||
double balance;
|
double balance;
|
||||||
|
|
||||||
}; /* ----- end of class Account ----- */
|
}; /* ----- end of class Account ----- */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// vim:set sts=2 sw=2 et:
|
||||||
|
|
21
main.cpp
21
main.cpp
|
@ -3,15 +3,15 @@
|
||||||
*
|
*
|
||||||
* Filename: main.cpp
|
* Filename: main.cpp
|
||||||
*
|
*
|
||||||
* Description:
|
* Description: learning C++ [again]
|
||||||
*
|
*
|
||||||
* Version: 1.0
|
* Version: 1.0
|
||||||
* Created: 02/08/2025 11:05:02 AM
|
* Created: 02/08/2025 11:05:02 AM
|
||||||
* Revision: none
|
* Revision: none
|
||||||
* Compiler: gcc
|
* Compiler: g++
|
||||||
*
|
*
|
||||||
* Author: YOUR NAME (),
|
* Author: Vincent Batts (vbatts@hashbangbash.com)
|
||||||
* Organization:
|
* Organization: HashBangBash
|
||||||
*
|
*
|
||||||
* =====================================================================================
|
* =====================================================================================
|
||||||
*/
|
*/
|
||||||
|
@ -24,10 +24,13 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
Account account(0.0);
|
Account account(0.0);
|
||||||
account.deposit(100.5); // Add some money
|
|
||||||
account.deposit(50.25); // Add more money
|
|
||||||
std::cout << "Current Balance: " << account.getBalance() << std::endl;
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
account.deposit(100.5); // Add some money
|
||||||
|
account.deposit(50.25); // Add more money
|
||||||
|
std::cout << "Current Balance: " << account.getBalance() << std::endl;
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vim:set sts=2 sw=2 et:
|
||||||
|
|
Loading…
Add table
Reference in a new issue