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 7659775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:22:39+00:00 2026-05-31T13:22:39+00:00

I’m relatively new to C++, and having an issue passing a string. I have

  • 0

I’m relatively new to C++, and having an issue passing a string. I have 2 constructors for a class, Transaction.” One constructor accepts a string and a double as its parameters, while the other accepts just a string.

When I attempt to pass the lines below, I get an error, saying:

no matching function for call to 'Account::addTransaction(const char [14])'

or

no matching function for call to 'Account::addTransaction(const char [11], double&)'

I know that there’s no matching function, because I’m passing a string! Here’s what I’m passing in:

bank.getAccount(index).addTransaction("Close Account");
bank.getAccount(index).addTransaction("Withdrawal", amount_to_withdraw);

I don’t know how to make it any more explicit that the first parameter is a string. Any advice would be greatly appreciated.

Thanks,
Adam

Updating per @g24l ‘s request:

Here is the Transaction Class:

#ifndef TRANSACTION_H
#define TRANSACTION_H

#include <iostream>
#include <string>
using namespace std;

class Transaction {

private:
    string transType;
    double transAmount;

/*
 public constructors:
 * 1st constructor is the default constructor
 * 2nd constructor is for non-monetary transactions
 * 3rd constructor is for transactions involving money
 */
public:
    Transaction() {
        transType = "";
    }
    Transaction(string tType) {
        transType = tType;
    }

    Transaction(string tType, double tAmount) {
        transType = tType;
        transAmount = tAmount;
    }

    void setTransType(string);
    void setTransAmount(double);

    string getTransType() const;
    double getTransAmount() const;
};
#endif  /* TRANSACTION_H */

In the Account class, which uses dynamic memory allocation for an array of transactions, I have:

class Account{
private:
    Depositor depositor;
    int accountNum;
    string accountType;
    double accountBalance;
    string accountStatus;
    Transaction *transptr;
    int numTransactions; //number of transactions

public:
    // public member functions prototypes

    // Constructors

    /* Account default constructor:
     * Input:
     *  Depositor() - calls the default depositor constructor
     * Process:
     *  sets object's data members to default values
     * Output:
     *  object's data members are set
     */

    Account()
    {
        //cout << "Account default constructor is running" << endl;
        Depositor();
        accountNum = 0;
        accountType = "";
        accountBalance = 0.0;
        accountStatus = "open";
        transptr = new Transaction[100];
        numTransactions = 0;
    }

I’m wondering if, when I declare the array of Transactions, it fills in all of the Transactions with the default constructor parameters. When I “add” a transaction I’m really writing over the existing transaction.

  • 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-05-31T13:22:39+00:00Added an answer on May 31, 2026 at 1:22 pm

    bank.getAccount.addTransaction takes a Transaction as a parameter. So pass it one:

    bank.getAccount(index).addTransaction(Transaction("Close Account"));
    bank.getAccount(index).addTransaction(Transaction("Withdrawal", amount_to_withdraw));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a text area in my form which accepts all possible characters from
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.