Error Problem

This is a discussion on Error Problem within the C++ Programming forums, part of the General Programming Boards category; I've been working on this homework problem for a bit and I think I have it solved except I'm running ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    Error Problem

    I've been working on this homework problem for a bit and I think I have it solved except I'm running into an error code

    >Hw_3.obj : error LNK2019: unresolved external symbol "void __cdecl printTable(double,double,double,int)" (?printTable@@YAXNNNH@Z) referenced in function "void __cdecl process(void)" (?process@@YAXXZ)
    1>Hw_3.obj : error LNK2019: unresolved external symbol "public: __thiscall Mortgage::Mortgage(double,double,int)" (??0Mortgage@@QAE@NNH@Z) referenced in function "void __cdecl process(void)" (?process@@YAXXZ)

    It's referring to something in:

    Code:
    Mortgage mtg(Loan, rate, term);
    
    double calc_payment(double Loan, double rate, int term);
    {
    	payment = Loan * term / (1 - pow(1 + rate, -term));
    }
    
    
    void printTable(double payment, double Loan, double rate, int term);
    {
    cout << setw(14) << "Interest" << setw(10) << "Principal" << endl;
    	cout << setw(14) << "--------" << setw(10) << "---------" << endl;
    
    	double	total_principal = 0;				// total of payments applied to principal
    	double	total_interest = 0;				// total of payments applied to interest
    
    	for (int i = 0; i < term; i++)				// print each payment
    	{
    		double to_interest = Loan * rate;		// periodic interest
    		double to_principal = payment - to_interest;	// principal part of payment
    
    		Loan -= (payment - to_interest);
    		total_interest += to_interest;
    		total_principal += to_principal;
    
    		cout << setw(3) << i + 1 << ":" <<
    			setw(10) << to_interest << setw(10) << to_principal << endl;
    	}
    
    	cout << endl << setw(14) << total_interest << setw(10) << total_principal << endl;
    
    }
    void display();
    	cout << "Mortgage Summary : \n\n";
    	cout << "Principal : " << Loan;
    	cout << "\nAnnual Rate : " << rate << "%\n";
    	cout << "Term : " << term << "\n";
    	cout << "Monthly Payment : " << payment << "\n\n";
    
    	printf("Do you want to print the payment table? (Y/N) ");
    	cin >> resp;
    	if ( resp[0] == 'Y' || resp[0] == 'y')
    		printTable(payment, Loan, rate, term);
    	else return;
    }
    And I have no idea how to fix it, any help or pointers would be appreciated.

  2. #2
    printf("Hello Cboard\n"); codeprada's Avatar
    Join Date
    Jan 2011
    Location
    In a little room at the back of your brain
    Posts
    68
    remove the semicolons from your function names

    Code:
    double calc_payment(double Loan, double rate, int term);
    {
        //your code
    }
    should be

    Code:
    double calc_payment(double Loan, double rate, int term)
    {
        //your code
    }
    correct
    Code:
    void printTable(double payment, double Loan, double rate, int term);
    and
    Code:
    void display();

    Code:
    Mortgage mtg(Loan, rate, term);
    ^this one is right though since you're only declaring it
    Last edited by codeprada; 02-13-2011 at 07:31 PM.
    We shouldn't be quick to criticize unless we can do better.
    Code:
    public function __clone() { die ( "I'm one of a kind" ); }

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21