Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8495921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:42:36+00:00 2026-06-10T23:42:36+00:00

This is my first time posting to this site, therefore I would appreciate all

  • 0

This is my first time posting to this site, therefore I would appreciate all criticisms in a constructive manner. I am learning to write Object Oriented programming with C++ and decided to make a trivial simulation of an ATM machine that takes in user input and processes it (i.e makeDeposit, checkBalance, etc.).

My Problem: BankAccount method: makeDeposit end up changing the output of getBalance() to prefix with a zero:
for example: makeDeposit(10) will change getBalance() from 0 -> 010.

`//BankAccout.h
#ifndef BANK_ACCOUNT_H
#define BANK_ACCOUNT_H
#include <string>
class BankAccount {

private:
    float m_accountBalance;
public:
    BankAccount ();
    float getBalance();

    /*Can I pass by value or would reference be necessary?*/
    void makeDeposit(BankAccount&, int);

};

#endif`



   //BankAccout.cpp
#include "BankAccount.h"

#include <iostream> //remove once done
using namespace std; //remove once done

BankAccount::BankAccount () {
    m_accountBalance = 0;
}

float BankAccount::getBalance() {
    return m_accountBalance;
}

//increment the object balance based on ammount
void BankAccount::makeDeposit(BankAccount &bao, int deposit_amount) {
    bao.m_accountBalance += deposit_amount;
}



int main () {
    BankAccount b1;
    cout << b1.getBalance(); //returns 0
    b1.makeDeposit (b1,1); //returns 01
    cout << b1.getBalance();
    //Ex.
    //makeDepost(b2, 10);
    //b2.getBalance(); will retrun 010

    return 0;
}

Any tips would also be much appreciated as I am about to take the roughest Data Structures course with little experience with object oriented programming.

Also, could someone explain to me what subversion is and how it is used.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:42:38+00:00Added an answer on June 10, 2026 at 11:42 pm

    You just print the 0 value to the console, then add the 1 to the balance and again prints the balance to the console. Result? 01.

    How to avoid it? Add << endl to the end of the every cout. You will print every value in separate line then. Example:
    cout << b1.getBalance(); change to cout << b1.getBalance() << endl;

    Your second question (altough it’s not related with the first one):
    Subversion (called also SVN) is a software versioning system. You can do backups often with it and – before everything – you can work with your project collaboratively with your team. More info: http://en.wikipedia.org/wiki/Apache_Subversion

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first time posting on StackOverflow but this site is awesome. Thanks
first time posting here, but god know's I use this site to search for
This is my first time posting something, first of all you got to know
This is my first time posting a question on this site, but certainly not
this is my first time posting here, I have a question which I have
use this website a lot but first time posting. My program creates a number
That's my first time posting on stackoverflow. I've been finding usefull answers on this
this is my first time posting on here and have read alot of helpful
Hey guys, this is my first time actually posting at stackflow but i've used
This is my first time posting to stackoverflow, but these threads have helped me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.