Unresolved Externals and how to the Total in?
Oct 4, 2012 at 2:39am UTC
I'm compiling my code and keep running into the same error
1>------ Build started: Project: Mailhouses, Configuration: Debug Win32 ------
1> MailhouseSource.cpp
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>c:\users\chris\documents\visual studio 2010\Projects\Mailhouses\Debug\Mailhouses.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I don't see the external I'm missing, and I'm wondering how to get the bottom commented out total into this code so at the bottom of the console it will give me a final price. Any help would be appreciated.
My header file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
//Mailhouse header
#include <string>
using namespace std;
//Product Definition
class Product
{
public :
Product ( string ); //Constructor
void inputProduct();
void displayProduct();
private :
int prod1Count;
int prod2Count;
int prod3Count;
int prod4Count;
int prod5Count;
};
My main file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
//Mail Order Houses
//header
#include <iostream>
#include "Mailhouseh.h"
using namespace std;
//labels and values
double product1 = 2.98;
double product2 = 4.50;
double product3 = 9.98;
double product4 = 4.49;
double product5 = 6.87;
double prod1Total;
double prod2Total;
double prod3Total;
double prod4Total;
double prod5Total;
double completeTotal;
//Counters
Product:: Product (string name)
{
prod1Count = 0;
prod2Count = 0;
prod3Count = 0;
prod4Count = 0;
prod5Count = 0;
}
//Switch statements
void Product::inputProduct()
{
int product;
cout << "Enter a number between 1 and 5" << endl;
while ( (product =cin.get() ) != -1)
{
switch ( product )
{
case '1' :
++prod1Count;
break ;
case '2' :
++prod2Count;
break ;
case '3' :
++prod3Count;
break ;
case '4' :
++prod4Count;
break ;
case '5' :
++prod5Count;
break ;
} //end switch
//Totals per product
}//end while
}//end function inputProduct
void Product::displayProduct()
{
prod1Total = prod1Count*product1;
prod2Total = prod2Count*product2;
prod3Total = prod3Count*product3;
prod4Total = prod4Count*product4;
prod5Total = prod5Count*product5;
cout << "\n Product 1:" << prod1Total
<< "\n Product 2:" << prod2Total
<< "\n Product 3:" << prod3Total
<< "\n Product 4:" << prod4Total
<< "\n Product 5:" << prod5Total
<<endl;
};
//Total for sale
// {
// completeTotal = prod1Total + prod2Total + prod3Total + prod4Total + prod5Total;
//cout << "Your total is:" << completeTotal <<endl;
// }
Oct 4, 2012 at 3:00am UTC
where is your main?
Oct 4, 2012 at 6:54pm UTC
At the moment it doesn't have one. So using the above code where would you put it? Everything I have is in a class.
Oct 4, 2012 at 7:16pm UTC
I'm being told the simpler way is to un class everything. Does this make sense?
Oct 4, 2012 at 7:31pm UTC
So using the above code where would you put it?
Only you can answer that.
Which is the first line of code which you want to be executed?
And where do you want the program to finish?
Topic archived. No new replies allowed.