0

I'm building a program that reads in states(strings) and tax rates(floats) from an input file and stores it into a vector of objects of a class called TaxBill. The class has 3 data members called stateName, taxBill, and index. There are also set()/get() functions for each respective data member.

Now, I don't have a question regarding my code (it is incomplete, but I'm still working on it). I am getting this error every time I try to compile it.

1>------ Build started: Project: Michael Bagnasco - CSIS 112(2), Fall 2016 - Lab 4, Configuration: Debug Win32 ------
1>Michael Bagnasco - CSIS 112(2), Fall 2016 - Lab 4.obj : error LNK2019: unresolved external symbol "public: __thiscall TaxBill::TaxBill(void)" (??0TaxBill@@QAE@XZ) referenced in function "public: void __thiscall std::allocator<class TaxBill>::construct(class TaxBill *)" (?construct@?$allocator@VTaxBill@@@std@@QAEXPAVTaxBill@@@Z)
1>C:\Users\Bagnastayy\Documents\Visual Studio 2013\Projects\Michael Bagnasco - CSIS 112(2), Fall 2016 - Lab 4\Debug\Michael Bagnasco - CSIS 112(2), Fall 2016 - Lab 4.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I couldn't figure out what was wrong so I created a new project and imported my cpp and header files and I got the same error. I then created a new project using a different .NET framework(4.5.1, I was using 4.6.2 previously). Same error occurred. So then I tried making a project using .NET 4.5.1 and selecting "Empty Project" in the project creation menu. I got the same error.

So then I made a simple "Hello World" program to see if there wasn't something wrong with my compiler. The program ran just fine. Here is the output from the .log in the Debug folder.

1>Project "c:\Users\bagnastayy\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1.vcxproj" on node 2 (Build target(s)).
     1>ClCompile:
         C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt Source.cpp
         Source.cpp
       Link:
         C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"c:\users\bagnastayy\documents\visual studio 2013\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"c:\users\bagnastayy\documents\visual studio 2013\Projects\ConsoleApplication1\Debug\ConsoleApplication1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"c:\users\bagnastayy\documents\visual studio 2013\Projects\ConsoleApplication1\Debug\ConsoleApplication1.lib" /MACHINE:X86 Debug\Source.obj
         ConsoleApplication1.vcxproj -> c:\users\bagnastayy\documents\visual studio 2013\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe
     1>Done Building Project "c:\Users\bagnastayy\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1.vcxproj" (Build target(s)).

Can anyone tell me what's going on or what I did wrong? My code is below.

Michael Bagnasco - CSIS 112(2), Fall 2016 - Lab 4.cpp

// Michael Bagnasco
//CSIS 112 – Fall 2016
//Lab 4 - 

#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "TaxBill.h"
using namespace std;

const string ID = "Michael Bagnasco - CSIS 112(2), Fall 2016 - Lab 4";


int main()
{
    cout << endl << "Running Lab 4 . . . " << endl;
    cout << ID << endl;
    cout << "              Console Output" << endl << endl << endl;


    //  DEFINITIONS
    bool  noErrors = true;
    char  exit;
    ifstream fin;
    ofstream fout,
        errOut;
    const int SALARY = 100000,
        HOUSE = 267000,
        ANNUAL = 36000;
    vector<TaxBill> States(1);
    string stateName;
    double salesTax,
        propertyTax,
        incomeTax;
    int temp;

    //  ADMINISTRATIVE STUFF
    fin.open("Lab4.dat");
    fout.open(ID + ".out");
    errOut.open(ID + ".err");
    fout << ID << endl;
    fout << "               Main Report" << endl << endl << endl;
    errOut << ID << endl;
    errOut << "         ***  Error Report  ***" << endl << endl << endl;


    //  PROGRAM LOGIC

    //  FIRST READ LOOP
    for (int i = 0; fin >> stateName >> salesTax >> propertyTax >> incomeTax; i++)
    {
        //  NAMING STATES IN VECTOR AND SIZING VECTOR
        States.at(i).setStateName(stateName);
        States.resize(i + 1);

    }
    cout << States.size();
    temp = States.size();
    int taxRates[5][4];

    //  SECOND READ LOOP
    for (int i = 0; fin >> stateName >> salesTax >> propertyTax >> incomeTax; i++)
    {

    }



    //EXIT ROUTINE
    errOut << endl << endl;
    fout << endl << endl;
    cout << endl << endl;

    if (noErrors)
        errOut << "No Errors Were Detected" << endl << endl << endl;

    errOut << "END OF ERROR REPORT";
    fout << "END OF MAIN REPORT";
    cout << "Enter any key to end execution of this program   . . .   ";
    cin >> exit;                                             //to pause program
    return 0;
}

TaxBill.h

// TaxBill Class Interface


#include <iostream>
#include <string>

using namespace std;


#ifndef _TAXBILL_H_
#define _TAXBILL_H_


class TaxBill
{
public:
    TaxBill();
    void setStateName(string);
    void setTaxBill(double);
    void setIndex(int);
    string getStateName();
    double getTaxBill();
    int getIndex();

private:
    string stateName;
    double taxBill;
    int index;
};

#endif 

TaxBill.cpp

#include "TaxBill.h"

void TaxBill::setStateName(string inName)
{
    stateName = inName;
}


void TaxBill::setTaxBill(double inBill)
{
    taxBill = inBill;
}


void TaxBill::setIndex(int inIndex)
{
    index = inIndex;
}


string TaxBill::getStateName()
{
    return stateName;
}


double TaxBill::getTaxBill()
{
    return taxBill;
}


int TaxBill::getIndex()
{
    return index;
}
Mike Bagnasco
  • 47
  • 1
  • 9

0 Answers0