How can I fix “error C2146: syntax error : missing ';'”?How can I profile C++ code running on Linux?C++ where to place includesWhat is an undefined reference/unresolved external symbol error and how do I fix it?Visual Studio 2008 Windows SDK Compiler ErrorIs it possible to define another preprocessor directive?Syntax error for string member variable in classClass Identifiers Never Work?c++, syntax error : missing ';' before identifier 'N0'Error C2146 & C4430typedef in class. In another class error: type has not been declared

Did Apple bundle a specific monitor with the Apple II+ for schools?

2019 gold coins to share

Who won a Game of Bar Dice?

The usage of kelvin in formulas

Why do radiation hardened IC packages often have long leads?

What is the color of artificial intelligence?

Electricity free spaceship

How to write a convincing religious myth?

What would be the way to say "just saying" in German? (Not the literal translation)

How to make the letter "K" that denote Krylov space

Amplitude of a crest and trough in a sound wave?

Ability To Change Root User Password (Vulnerability?)

Why does this query, missing a FROM clause, not error out?

How can I remove material from this wood beam?

Who voices the small round football sized demon In Good Omens

Do you have to have figures when playing D&D?

What is this Amiga 1200 mod?

tabular: caption and align problem

Does a bank have to tell me if a check made out to me was cashed there?

Please figure out this Pan digital Prince

C++ logging library

Getting UPS Power from One Room to Another

Who is "He that flies" in Lord of the Rings?

Can I utilise a baking stone to make crepes?



How can I fix “error C2146: syntax error : missing ';'”?


How can I profile C++ code running on Linux?C++ where to place includesWhat is an undefined reference/unresolved external symbol error and how do I fix it?Visual Studio 2008 Windows SDK Compiler ErrorIs it possible to define another preprocessor directive?Syntax error for string member variable in classClass Identifiers Never Work?c++, syntax error : missing ';' before identifier 'N0'Error C2146 & C4430typedef in class. In another class error: type has not been declared






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















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:usersalexdropboxlab4lab4lab4customer.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
;









share|improve this question
























  • Looks like you didn't define RentalHistory. Can we see your headers?

    – Mysticial
    Dec 10 '11 at 1:50







  • 2





    It's possible that the error is in customerdata.h, rentalhistory.h, item.h, or customer.h. Simplify your code even more so that we can actually compile it and try it ourselves. Read sscce.org

    – David Grayson
    Dec 10 '11 at 1:51












  • David Grayson, thanks for the link. Next time I post I'll prepare a SSCCE

    – ShrimpCrackers
    Dec 10 '11 at 2:11

















-1















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:usersalexdropboxlab4lab4lab4customer.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
;









share|improve this question
























  • Looks like you didn't define RentalHistory. Can we see your headers?

    – Mysticial
    Dec 10 '11 at 1:50







  • 2





    It's possible that the error is in customerdata.h, rentalhistory.h, item.h, or customer.h. Simplify your code even more so that we can actually compile it and try it ourselves. Read sscce.org

    – David Grayson
    Dec 10 '11 at 1:51












  • David Grayson, thanks for the link. Next time I post I'll prepare a SSCCE

    – ShrimpCrackers
    Dec 10 '11 at 2:11













-1












-1








-1








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:usersalexdropboxlab4lab4lab4customer.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
;









share|improve this question
















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:usersalexdropboxlab4lab4lab4customer.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
;






c++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 20:35









Jonathan Leffler

582k966961052




582k966961052










asked Dec 10 '11 at 1:49









ShrimpCrackersShrimpCrackers

1,957124359




1,957124359












  • Looks like you didn't define RentalHistory. Can we see your headers?

    – Mysticial
    Dec 10 '11 at 1:50







  • 2





    It's possible that the error is in customerdata.h, rentalhistory.h, item.h, or customer.h. Simplify your code even more so that we can actually compile it and try it ourselves. Read sscce.org

    – David Grayson
    Dec 10 '11 at 1:51












  • David Grayson, thanks for the link. Next time I post I'll prepare a SSCCE

    – ShrimpCrackers
    Dec 10 '11 at 2:11

















  • Looks like you didn't define RentalHistory. Can we see your headers?

    – Mysticial
    Dec 10 '11 at 1:50







  • 2





    It's possible that the error is in customerdata.h, rentalhistory.h, item.h, or customer.h. Simplify your code even more so that we can actually compile it and try it ourselves. Read sscce.org

    – David Grayson
    Dec 10 '11 at 1:51












  • David Grayson, thanks for the link. Next time I post I'll prepare a SSCCE

    – ShrimpCrackers
    Dec 10 '11 at 2:11
















Looks like you didn't define RentalHistory. Can we see your headers?

– Mysticial
Dec 10 '11 at 1:50






Looks like you didn't define RentalHistory. Can we see your headers?

– Mysticial
Dec 10 '11 at 1:50





2




2





It's possible that the error is in customerdata.h, rentalhistory.h, item.h, or customer.h. Simplify your code even more so that we can actually compile it and try it ourselves. Read sscce.org

– David Grayson
Dec 10 '11 at 1:51






It's possible that the error is in customerdata.h, rentalhistory.h, item.h, or customer.h. Simplify your code even more so that we can actually compile it and try it ourselves. Read sscce.org

– David Grayson
Dec 10 '11 at 1:51














David Grayson, thanks for the link. Next time I post I'll prepare a SSCCE

– ShrimpCrackers
Dec 10 '11 at 2:11





David Grayson, thanks for the link. Next time I post I'll prepare a SSCCE

– ShrimpCrackers
Dec 10 '11 at 2:11












1 Answer
1






active

oldest

votes


















5














The error message indicates that the compiler doesn't recognize RentalHistory as a type. If the type is correctly defined in the included rentalhistory.h, the most common reason for such a problem would be circular dependencies.



Does rentalhistory.h try to include customer.h? In this case you have circular includes that you need to resolve. In rentalhistory.h you would most likely have to add a forward declaration like class Customer; instead of including customer.h.



Also: Why does customer.h try to include itself?






share|improve this answer























  • Thanks, sth. You were right about the circular dependencies. I've included the forward declaration. Do I only include the header of the class I forward declarated in the .cpp file?

    – ShrimpCrackers
    Dec 10 '11 at 2:08











  • Yes, including the header in the .cpp file should do the right thing.

    – sth
    Dec 10 '11 at 2:09











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8453757%2fhow-can-i-fix-error-c2146-syntax-error-missing%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














The error message indicates that the compiler doesn't recognize RentalHistory as a type. If the type is correctly defined in the included rentalhistory.h, the most common reason for such a problem would be circular dependencies.



Does rentalhistory.h try to include customer.h? In this case you have circular includes that you need to resolve. In rentalhistory.h you would most likely have to add a forward declaration like class Customer; instead of including customer.h.



Also: Why does customer.h try to include itself?






share|improve this answer























  • Thanks, sth. You were right about the circular dependencies. I've included the forward declaration. Do I only include the header of the class I forward declarated in the .cpp file?

    – ShrimpCrackers
    Dec 10 '11 at 2:08











  • Yes, including the header in the .cpp file should do the right thing.

    – sth
    Dec 10 '11 at 2:09















5














The error message indicates that the compiler doesn't recognize RentalHistory as a type. If the type is correctly defined in the included rentalhistory.h, the most common reason for such a problem would be circular dependencies.



Does rentalhistory.h try to include customer.h? In this case you have circular includes that you need to resolve. In rentalhistory.h you would most likely have to add a forward declaration like class Customer; instead of including customer.h.



Also: Why does customer.h try to include itself?






share|improve this answer























  • Thanks, sth. You were right about the circular dependencies. I've included the forward declaration. Do I only include the header of the class I forward declarated in the .cpp file?

    – ShrimpCrackers
    Dec 10 '11 at 2:08











  • Yes, including the header in the .cpp file should do the right thing.

    – sth
    Dec 10 '11 at 2:09













5












5








5







The error message indicates that the compiler doesn't recognize RentalHistory as a type. If the type is correctly defined in the included rentalhistory.h, the most common reason for such a problem would be circular dependencies.



Does rentalhistory.h try to include customer.h? In this case you have circular includes that you need to resolve. In rentalhistory.h you would most likely have to add a forward declaration like class Customer; instead of including customer.h.



Also: Why does customer.h try to include itself?






share|improve this answer













The error message indicates that the compiler doesn't recognize RentalHistory as a type. If the type is correctly defined in the included rentalhistory.h, the most common reason for such a problem would be circular dependencies.



Does rentalhistory.h try to include customer.h? In this case you have circular includes that you need to resolve. In rentalhistory.h you would most likely have to add a forward declaration like class Customer; instead of including customer.h.



Also: Why does customer.h try to include itself?







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 10 '11 at 1:57









sthsth

171k44250338




171k44250338












  • Thanks, sth. You were right about the circular dependencies. I've included the forward declaration. Do I only include the header of the class I forward declarated in the .cpp file?

    – ShrimpCrackers
    Dec 10 '11 at 2:08











  • Yes, including the header in the .cpp file should do the right thing.

    – sth
    Dec 10 '11 at 2:09

















  • Thanks, sth. You were right about the circular dependencies. I've included the forward declaration. Do I only include the header of the class I forward declarated in the .cpp file?

    – ShrimpCrackers
    Dec 10 '11 at 2:08











  • Yes, including the header in the .cpp file should do the right thing.

    – sth
    Dec 10 '11 at 2:09
















Thanks, sth. You were right about the circular dependencies. I've included the forward declaration. Do I only include the header of the class I forward declarated in the .cpp file?

– ShrimpCrackers
Dec 10 '11 at 2:08





Thanks, sth. You were right about the circular dependencies. I've included the forward declaration. Do I only include the header of the class I forward declarated in the .cpp file?

– ShrimpCrackers
Dec 10 '11 at 2:08













Yes, including the header in the .cpp file should do the right thing.

– sth
Dec 10 '11 at 2:09





Yes, including the header in the .cpp file should do the right thing.

– sth
Dec 10 '11 at 2:09



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8453757%2fhow-can-i-fix-error-c2146-syntax-error-missing%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript