我不喜歡求人這樣一個常見的錯誤,但我一直在盯着我的代碼慫恿了兩個小時試圖找到編譯器說什麼是缺少分號和未指定類型:錯誤C2146:語法錯誤:缺少';'
錯誤C2146:語法錯誤:缺少';'在標識符'history'之前.....:
錯誤C4430: 缺少類型說明符 - int假定。注意:C++不支持 default-int 1> c:\ users \ alex \ dropbox \ lab4 \ lab4 \ lab4 \ customer.h(49): 錯誤C4430:缺少類型說明符 - int假定。注意:C++不 支持默認int
#pragma once
#include <string>
using std::string;
#include "customerdata.h"
#include "rentalhistory.h"
#include "item.h"
#include "customer.h"
/*---------------------------------------------------------------------------
Purpose: class Customer contains methods to grab information about a customer,
such as their id number, address, phone number (stored in class CustomerData).
It also contains methods that will allow access to information about a
customer’s rental history (stored in class RentalHistory).
CONSTRUCTION:
(1) empty construction. (2) name and id (3) with information provided by
CustomerData object.
--------------------------------------------------------------------------- */
class Customer
{
public:
Customer();
Customer(const Customer &);
Customer(string, string, int);
Customer(const CustomerData &);
~Customer();
// get customer's first name.
string getFirstName() const;
// get customer's last name.
string getLastName() const;
// get customer's id number
int getIdNum() const;
// add a movie to customer's rental history
void addMovie(Item *&, string code);
// checks to see if it is a valid customer
bool isValidCustomer();
// prints the customer's rental history
void printHistory() const;
Customer & operator=(Customer &rhs);
private:
CustomerData data; // object that contains customer's information
RentalHistory history; // object that contains customer's rental history
};
看起來你沒有定義'RentalHistory'。我們可以看到您的標題嗎? – Mysticial
錯誤可能在customerdata.h,rentalhistory.h,item.h或customer.h中。更簡化您的代碼,以便我們可以實際編譯它並自行嘗試。閱讀http://sscce.org –
David Grayson,感謝您的鏈接。下次我發帖時我會準備一份SSCCE – ShrimpCrackers