Thread: Linking Errors

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    45

    Linking Errors

    I got the program to work that i was using and then I decided to make another version of it where it will go through the process multiple times. I compile it and get no errors, but when i go to run it, i get these errors.

    error LNK2001: unresolved external symbol _WinMain@16

    fatal error LNK1120: 1 unresolved externals


    heres the code.
    Code:
    #include<iostream.h>
    
    class GroceryItem
    {
    	private:
    		int stockNum;
    		double priceEach;
    		int quantity;
    		double totalValue;
    		void calculateTotalValue(double, int);
    	public:
    		void setStockNum();
    		void setPriceEach();
    		void setQuantity();
    		void setGroceryVariables();
    		void displayGroceryItem(int, double, int, double);
    };
    
    void GroceryItem::setStockNum()
    {	
    	cout<<"Enter the Stock Number: ";
    	cin>>stockNum;
    
    };
    void GroceryItem::setPriceEach()
    {
    	cout<<"Enter the price: ";
    	cin>>priceEach;
    };
    void GroceryItem::setQuantity()
    {
    	cout<<"Enter the quantity in stock: ";
    	cin>>quantity;
    };
    void GroceryItem::calculateTotalValue(double, int)
    {
    	totalValue=priceEach*quantity;
    };
    void GroceryItem::displayGroceryItem(int, double, int, double)
    {
    	cout<<"Item #"<<stockNum<<" Price: "<<priceEach<<endl;
    	cout<<"Quantity in stock: "<<quantity<<" Value: "<<totalValue;
    };
    void GroceryItem::setGroceryVariables()
    {
    	setStockNum();
    	setPriceEach();
    	setQuantity();
    	calculateTotalValue(priceEach, quantity);
    	displayGroceryItem(stockNum, priceEach, quantity, totalValue);
    };
    int main()
    {
    
    	int num;
    	GroceryItem anItem;
    	for (num=1; num<3; ++num)
    	{
    		anItem.setGroceryVariables();
    	};
    
    
    }

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    you need to create a "console" application and not a "windows" app.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    45
    stupid me, i didn't notice that i made it an win32 app.. thanks. i would have never figured that out. heh

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking errors
    By Zeeshan in forum C++ Programming
    Replies: 1
    Last Post: 02-22-2009, 02:10 AM
  2. HELP!!Why and How to solve this linking errors.
    By huwan in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2007, 06:30 AM
  3. Replies: 8
    Last Post: 04-27-2006, 10:39 AM
  4. Linking Errors
    By ForlornOdium in forum C++ Programming
    Replies: 1
    Last Post: 12-07-2003, 10:24 PM
  5. Linking Errors...
    By c++_n00b in forum C++ Programming
    Replies: 9
    Last Post: 06-08-2002, 07:03 PM