0

我是 C++ 新手,所以请耐心等待。当我编译时我得到这个错误。包括cpp和头文件。这是我得到的错误:

1>------ Build started: Project: 12_6, Configuration: Debug Win32 ------
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\john\Documents\Visual Studio 2012\How to program\ch12_6\12_6\Debug\12_6.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

佣金雇员.h

#ifndef COMMISSION_H
#define COMMISSION_H

#include <string> // C++ standard string class
using namespace std;

class CommissionEmployee
{
public:
   CommissionEmployee( const string &, const string &, const string &, 
      double = 0.0, double = 0.0 );

   void setFirstName( const string & ); // set first name
   string getFirstName() const; // return first name

   void setLastName( const string & ); // set last name
   string getLastName() const; // return last name

   void setSocialSecurityNumber( const string & ); // set SSN
   string getSocialSecurityNumber() const; // return SSN

   void setGrossSales( double ); // set gross sales amount
   double getGrossSales() const; // return gross sales amount

   void setCommissionRate( double ); // set commission rate (percentage)
   double getCommissionRate() const; // return commission rate

   double earnings() const; // calculate earnings
   void print() const; // print CommissionEmployee object
private:
   string firstName;
   string lastName;
   string socialSecurityNumber;
   double grossSales; // gross weekly sales
   double commissionRate; // commission percentage
}; // end class CommissionEmployee

#endif

CommissionEmployee.cpp

4

1 回答 1

0

您似乎没有定义主要功能。一个程序需要有一个主函数。链接器期望它,如果它没有定义,那么它会阻塞。main 函数是程序的入口点,没有它,程序将无法启动。

于 2013-10-31T21:55:36.740 回答