main: got the variable onto the heap ...

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2025-02-10 16:52:07 -05:00
parent e62400400d
commit c91b7ee785
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED
2 changed files with 10 additions and 8 deletions

View file

@ -4,12 +4,13 @@
#include <iostream>
// https://www.geeksforgeeks.org/cpp-macros/#
#define log_out(hurr) \
std::cout << "[" << __FILE__ << ":" << __LINE__ << "] " << hurr << std::endl;
#define log_err(hurr) \
std::cerr << "[" << __FILE__ << ":" << __LINE__ << "] " << hurr << std::endl;
#endif // COMMON_H_INCLUDED_
// vim:set sts=2 sw=2 et:

View file

@ -24,19 +24,20 @@
#include "worker.h"
Account* do_account() {
Account account(0.0);
Account* account = new 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;
log_out("HERE");
return &account;
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();
Account* account = do_account();
log_out("HERE");
account->withdraw(100);
log_out("Current Balance: " << account->getBalance());
log_err("dang");
}