71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
// Copyright 2025 Vincent Batts <vbatts@hashbangbash.com>
|
|
/*
|
|
* =====================================================================================
|
|
*
|
|
* Filename: main.cpp
|
|
*
|
|
* Description: learning C++ [again]
|
|
*
|
|
* Version: 1.0
|
|
* Created: 02/08/2025 11:05:02 AM
|
|
* Revision: none
|
|
* Compiler: g++
|
|
*
|
|
* Author: Vincent Batts (vbatts@hashbangbash.com)
|
|
* Organization: HashBangBash
|
|
*
|
|
* =====================================================================================
|
|
*/
|
|
#include <iostream>
|
|
#include <cmath>
|
|
#include <cstdlib>
|
|
#include <cassert>
|
|
|
|
#include "./common.h"
|
|
#include "./account.h"
|
|
#include "./worker.h"
|
|
|
|
Account* do_account() {
|
|
Account* account = new Account(0.0);
|
|
assert(account);
|
|
if (nullptr == account) {
|
|
log_err("failed to allocate account");
|
|
return nullptr;
|
|
}
|
|
|
|
account->deposit(100.5); // Add some money
|
|
account->deposit(50.25); // Add more money
|
|
log_out("Current Balance: " << account->getBalance());
|
|
return account;
|
|
}
|
|
|
|
void scoped_account() {
|
|
log_out("HERE");
|
|
auto account = do_account();
|
|
if (nullptr == account) {
|
|
log_err("failed to allocate account");
|
|
return;
|
|
}
|
|
log_out("HERE");
|
|
account->withdraw(100);
|
|
log_out("Current Balance: " << account->getBalance());
|
|
log_err("dang");
|
|
delete account;
|
|
}
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
int ret;
|
|
|
|
scoped_account();
|
|
|
|
Dang::Worker worker;
|
|
ret = worker.work();
|
|
if (ret != 0) {
|
|
std::cout << "worker failed" << std::endl;
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|
|
// vim:set sts=2 sw=2 et:
|