factordva's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
New Members
Active Posts:
7 (0.03 per day)
Joined:
08-September 12
Profile Views:
630
Last Active:
User is offline Sep 08 2012 09:45 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   factordva has not set their status

Posts I've Made

  1. In Topic: Object is initializing to unwanted value

    Posted 8 Sep 2012

    My question has been answered.

    I was supposed to use:
    cout << "Current balance is now: " << m_bao.getBalance() << '\n';
    


    instead of:
    cout << "Current balance is now: " << m_bao.getBalance() + '\n';
    
  2. In Topic: Object is initializing to unwanted value

    Posted 8 Sep 2012

    Jim,

    I kind of lost you. I attempted making a default and secondary constructor that sets to zero, but I keep having the problem of my current balance automatically being set to $10.
  3. In Topic: Object is initializing to unwanted value

    Posted 8 Sep 2012

    @skydiver

    so I changed my constructor to:

    //In BankAccount.cpp
    BankAccount::BankAccount(float deposit) {
    	balance = deposit;
    }
    
    


    Here is my main which I test from:

    int main () {
    	
    	BankAccount checking(0.00);
    	Transaction q(checking);
    	q.displayOptions(); 
    	q.printReciept();
    	
    	
    }
    


    I am getting a compile time error: no matching function for call to BankAccount::BankAccount()
    Canidates are: BankAccount::BankAccount(float)
    or BankAccount::BankAccount(const BankAccount&)

    What is this error?
  4. In Topic: function prints undesired value

    Posted 8 Sep 2012

    @skydiver, wow thanks for your reply. I knew at first that it was redundant to add that parameter especially since it was already inside the object. Did I address my problem?
    //added this and removed the first parameter
    void BankAccount::makeDeposit(float deposit_amount) {
    	this->m_accountBalance += deposit_amount;
    }
    
    void BankAccount::makeWithdrawl(float withdrawl_amount) {
    	this->m_accountBalance -= withdrawl_amount;
    }
    
    
    

    int main () {
    	BankAccount checking;
    	BankAccount savings;
    	checking.makeDeposit (100);
    	savings.makeDeposit (200);
    	cout << checking.getBalance() << '\n'; //returns 100
    	cout << savings.getBalance() << '\n'; // returns 200
    	
    	checking.makeWithdrawl (20);
    	savings.makeWithdrawl (20);
    	cout << checking.getBalance() << '\n'; //returns 80
    	cout << savings.getBalance() << '\n'; // returns 180
    	
    	
    	return 0;
    }
    
    
  5. In Topic: function prints undesired value

    Posted 8 Sep 2012

    View PostTwoOfDiamonds, on 08 September 2012 - 02:22 AM, said:

    Firstly , the output error you get is because you print the digits one after another, try to end your output lines with <<endl;
    Like
    cout<<b2.getBalance<<endl;
    

    Also I think it's useless to have the m_accountBalance; and getBalance(); as floats as long as you will only add integers to m_accountBalance which is initialized to 0 by the constructor, you might want to rethink that and maybe change makeDeposit(BankAccount&, int); to makeDeposit(BankAccount&, float);


    I cant believe I didn't notice that, thank you for your quick reply.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

Comments

factordva has no profile comments yet. Why not say hello?