LNK2019 & LNK1120

Hey guys,

I have been working on this code for days now and I thought I finally got it all figured out but then I got these two errors when I went to build it. I have tried everything and can't figure it out. Any help would be greatly appreciated!

Error 1: Error 1 error LNK2019: unresolved external symbol "public: double __thiscall Inventory::GetMarkUp(void)const " (?GetMarkUp@Inventory@@QBENXZ) referenced in function "public: void __thiscall Inventory::Display(void)const " (?Display@Inventory@@QBEXXZ) C:\Users\documents\visual studio 2012\Projects\StoreInventory\StoreInventory\Inventory.obj StoreInventory

Error 2: Error 2 error LNK1120: 1 unresolved externals C:\Users\Sarah\documents\visual studio 2012\Projects\StoreInventory\Debug\StoreInventory.exe StoreInventory


CODE:

H.file
//Header File or Specificaion File
//Filename: Inventory.h

#pragma once

#ifndef INVENTORY_H
#define INVENTORY_H

#include <iostream>
#include <iomanip>

using namespace std;

class Inventory
{
public:

Inventory();
Inventory(int ProductNumber, char ProductDescription[50], int ManufactureNumber, double WholesalePrice, int ProductInventory, double MarkUp);


int GetProductNumber() const;
char* GetProductDescription() const;
int GetManufactureNumber() const;
double GetWholesalePrice() const;
int GetProductInventory() const;
double GetRetailPrice() const;
double GetMarkUp() const;

void Display() const;




private:

int ProductNumber;
int ManufactureNumber;
double WholesalePrice;
int ProductInventory;
double MarkUp;

mutable char ProductDescription[50];


};




#endif

_______________________
Inventory.cpp

//Implementation File
//Filename: Inventory.cpp

#include "Inventory.h"
#include "stdafx.h"

// Constructors
Inventory::Inventory()
{
ProductNumber = 0;
ProductDescription [49] = '\0';
ManufactureNumber = 0;
WholesalePrice = 0;
ProductInventory = 0;
}
Inventory::Inventory (int InitProductNumber, char InitProductDescription[], int InitManufactureNumber, double InitWholesalePrice, int InitProductInventory, double InitMarkUp)
{
ProductNumber = InitProductNumber;
strcpy_s(ProductDescription, InitProductDescription );
ManufactureNumber = InitManufactureNumber;
WholesalePrice = InitWholesalePrice;
ProductInventory = InitProductInventory;
MarkUp = InitMarkUp;
}
// Return the values of the private class members

int Inventory::GetProductNumber () const
{
return (ProductNumber);
}

char* Inventory::GetProductDescription() const
{
return (ProductDescription);
}

int Inventory::GetManufactureNumber () const
{
return (ManufactureNumber);
}

double Inventory::GetWholesalePrice () const
{
return (WholesalePrice);
}

int Inventory::GetProductInventory () const
{
return (ProductInventory);
}

double Inventory::GetRetailPrice () const
{
return((WholesalePrice*MarkUp)+WholesalePrice);
}


//Display Information Concerning Store Inventory

void Inventory::Display() const
{
char Separator[50] = "_______________________________________";

// Display header for Store Inventory Information
cout << endl << Separator << endl << endl;
cout << setw(40) << setfill(' ') << "Office Supply Product Information" << endl;
cout << Separator;
cout << endl << endl << setw(20) << setfill(' ') << "Identification Number:"
<< setw(15) << setfill(' ') << "Description:"
<< setw(20) << setfill(' ') << "Manufacturer:"
<< setw(12) << setfill(' ') << "Wholesale Price:" << endl
<< setw(20) << setfill(' ') << "Mark-Up Percentage:"
<< setw(20) << setfill(' ') << "Quantity In Stock:"
<< endl << Separator << endl << Separator << endl;

// Display data for Store Inventory

cout << right;
cout << endl << setw(10) << setfill(' ') << GetProductNumber();
cout << setw(20) << setfill(' ') << GetProductDescription();
cout << setw(15) << setfill(' ') << GetManufactureNumber();
cout << setw(15) << setfill(' ') << GetWholesalePrice();
cout << setw(15) << setfill(' ') << GetMarkUp();
cout << setw(15) << setfill(' ') << GetProductInventory();
cout << fixed << showpoint << setprecision(2)
<< setw(14) << setfill(' ')
<< "$" << GetRetailPrice()
<< endl;
cout << Separator << endl;
}
__________________________________
Main.cpp

//Client Code File
//Filename: InventoryClientCode.cpp

#include "stdafx.h"
#include "Inventory.h"

int main()
{
int InitProductNumber = 0;
char InitProductDescription [50] = "\0";
int InitManufactureNumber = 0;
double InitWholesalePrice = 0;
int InitProductInventory = 0;
double InitMarkUp = 0;


char NextChar= '\0';
char ContinuationFlag = 'Y';

while (toupper (ContinuationFlag) == 'Y')
{
cout << endl;
cout << "Enter The Product's Identification Number:" << endl;
cin >> InitProductNumber;
cout << "Enter The Product's Manufacturer's Identification Number:" << endl;
cin >> InitManufactureNumber;
cout << "Enter The Product's Wholesale Price:" << endl;
cin >> InitWholesalePrice;
cout << "Enter The Product's Mark-Up Percentage:" << endl;
cin >> InitMarkUp;
cout << "Enter The Product's Description:" << endl;
cin >> InitProductDescription;

NextChar = cin.peek();

if (NextChar == '\n')
{
cin.ignore();
}
cin.get( InitProductDescription, 49);
cout << "Enter The Quantity Of The Product In Stock:" << endl;
cin >> InitProductInventory;

Inventory InventoryItem (InitProductNumber, InitProductDescription, InitManufactureNumber, InitWholesalePrice, InitProductInventory, InitMarkUp);

InventoryItem.Display();
double RetailPrice = InventoryItem.GetRetailPrice();

cout << endl
<< "Office Supply Product Retail Price:" << endl;
cout << RetailPrice << endl;
cout << "Do you wish to enter any more products?"
<< endl;
cout << "Enter 'Y' or 'N'"<<endl;

cin >> ContinuationFlag;
}
return 0;
}
Last edited on
closed account (48T7M4Gy)
Assuming it was running OK before, Clean and Rebuild from the VS menu might be the go.
It was working before when I used Getters/Setters but the instructor wanted us to const instead of set. After I changed it, I received the error referenced above.

I did clean and rebuild in VS but I'm still getting the same error. I also tried it again and I'm still getting the error.
closed account (E0p9LyTq)
So where is the implementation of your GetMarkup() class method? You have declared it, but you never defined it. Maybe you removed it?

The errors you received pointed exactly to what the problem is, "unresolved external symbol/unresolved symbols" means the compiler couldn't find the code for the function.

PLEASE learn to use code tags, it makes it MUCH easier to read your code:
http://www.cplusplus.com/articles/jEywvCM9/

1
2
3
4
5
6
#include <iostream>

int main() 
{
   std::cout << "Using Code Tags is FUN!\n";
}


Topic archived. No new replies allowed.