I hate to ask for help on such a common error but I’ve been staring and prodding at my code for two hours trying to find what the compiler says is a missing semi-colon and unspecified type:
error C2146: syntax error : missing ‘;’ before identifier ‘history’…..:
error C4430:
missing type specifier – int assumed. Note: C++ does not support
default-int 1>c:\users\alex\dropbox\lab4\lab4\lab4\customer.h(49):
error C4430: missing type specifier – int assumed. Note: C++ does not
support default-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
};
The error message indicates that the compiler doesn’t recognize
RentalHistoryas a type. If the type is correctly defined in the includedrentalhistory.h, the most common reason for such a problem would be circular dependencies.Does
rentalhistory.htry to includecustomer.h? In this case you have circular includes that you need to resolve. Inrentalhistory.hyou would most likely have to add a forward declaration likeclass Customer;instead of includingcustomer.h.Also: Why does
customer.htry to include itself?