Please Help!! I am writing a c++ program that is a basic bank account program. I have tried to figure out what my problem is, but I have been unable to determine the problem in my code. I compile all of my source files to object code. When I am trying to create my executable file, I receive the following error:
undefined reference to `Customer::Customer[in-charge]()`
This is driving me crazy!!!!
Here is my code:
Bankaccount.h:
#ifndef _BankAccount_h_
#define _BankAccount_h_
#include <stdio.h>
#include <string>
using std::string;
class BankAccount
{
private:
float interest, balance;
string accountType;
public:
//Constructor
BankAccount();
//Accessor Methods
void setInterest(float interestIn) {interest = interestIn;}
float getInterest() {return interest;}
void setType(string typeIn) {accountType = typeIn;}
string getType() {return accountType;}
float getBalance() {return balance;}
//Deposit Method
void deposit(float amount);
//Withdrawal Method
void withdrawal(float amount);
//Total Balance Method - computer balance with interest
void totalBalance();
};
#endif
BankAccount.C
#include "BankAccount.h"
#include <stdio.h>
#include <string>
// Constructor
BankAccount::BankAccount()
{
interest = 0.0;
balance = 0.0;
}
// Deposit Method
void BankAccount::deposit(float amount)
{
balance += amount;
totalBalance();
}
// Withdrawal Method
void BankAccount::withdrawal(float amount)
{
balance -= amount;
totalBalance();
}
// Total Balance Method
void BankAccount::totalBalance()
{
balance = balance + balance*interest;
}
Customer.h:
#ifndef _Customer_h_
#define _Customer_h_
#include <stdio.h>
#include <string>
#include "BankAccount.h"
using std::string;
class Customer
{
private:
string firstName, lastName, street, city, state;
int zip, SS;
BankAccount account;
public:
//Default Constructor
Customer();
//Constructor
Customer(string firstIn, string lastIn, string streetIn, string cityIn, string stateIn,
int zipIn, int SSIn, string acctTypeIn, float interestIn, float depositIn)
{
firstName = firstIn;
lastName = lastIn;
street = streetIn;
city = cityIn;
state = stateIn;
zip = zipIn;
SS = SSIn;
account.setType(acctTypeIn);
account.setInterest(interestIn);
account.deposit(depositIn);
}
//Accessor Methods
void setFirst(string firstIn) {firstName = firstIn;}
string getFirst() {return firstName;}
void setLast(string lastIn) {lastName = lastIn;}
string getLast() {return lastName;}
void setStreet(string streetIn) {street = streetIn;}
string getStreet() {return street;}
void setCity(string cityIn) {city = cityIn;}
string getCity() {return city;}
void setState(string stateIn) {state = stateIn;}
string getState() {return state;}
void setZip(int zipIn) {zip = zipIn;}
int getZip() {return zip;}
void setSS(int SSIn) {SS = SSIn;}
int getSS() {return SS;}
BankAccount &getAccount() {return account;}
//method to print customer information to screen
void printCustomer();
};
#endif
Customer.C:
#include <stdio.h>
#include <string>
#include "Customer.h"
using std::string;
//printCustomer method
void Customer:
rintCustomer()
{
printf("%-10s %15s %12d %15s %5.2f %14.2f\n", &firstName, &lastName, SS, "Checking *fix*",
account.getInterest(), account.getBalance());
printf("%s %s, %s %d\n\n", &street, &city, &state, zip);
}
testapp.C:
#include <stdio.h>
#include <string>
#include "Customer.h"
main()
{
Customer customers;
customers.setFirst("Drew");
customers.setLast("Wolske");
customers.setStreet("514 S. Edwin St");
customers.setCity("Champaign");
customers.setState("IL");
customers.setZip(61821);
customers.setSS(35078);
customers.getAccount().setType("Checking");
customers.getAccount().setInterest(10.0);
customers.getAccount().deposit(500.00);
customers.printCustomer();
}
Any help would be great so I could continue with my assignment.
Thanks!