LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-11-2006, 04:04 PM   #1
DWo
LQ Newbie
 
Registered: Mar 2006
Posts: 1

Rep: Reputation: 0
Undefined Reference Linker Problem


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!
 
Old 03-11-2006, 04:17 PM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You're missing the curly braces after your default constructor, i.e. your line should be

Code:
Customer() {}
Also, you seem to be mixing C and C++ which is probably discouraged! Use [CODE] tags in future as well; it makes your code more readable.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"undefined reference"linker error for static field w/ C++ astorm Programming 5 08-27-2008 03:00 AM
problem of undefined reference to `__ctype_b' nelnel Programming 3 08-01-2007 01:40 AM
Glib-1.020 install problem Can't use an undefined value as a symbol reference jimdaworm Linux - Software 1 01-03-2004 05:32 AM
2.6-test9 compile problem - undefined reference to `ide_hwifs' saint Linux - General 5 11-20-2003 04:53 PM
Yet another 'undefined reference' problem faulpelz2 Linux - Software 3 04-04-2003 11:18 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration