Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 12th, 2004, 02:06 AM
Authorized User
 
Join Date: Aug 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Spivonious
Default unexpected end of file question

Yeah I know this usually means a semi-colon is missing, but I can't find it. Any guesses?

I'm using the VC++ 2005 Express Beta. I've included both files in my project (a wizard-formed .NET application)

//implementation of CCard

#include "CCard.h"

CCard::CCard()
{
    mSuit = Spades;
    mValue = Ace;
}

CCard::CCard(SUIT suit, int value)
{
    mSuit = suit;
    mValue = value;
}
And just for fun, here is CCard.h

enum SUIT {Hearts=0, Spades=1, Clubs=2, Diamonds=3};
enum FACECARD {Ace=1, Jack=11, Queen=12, King=13};

class CCard
{
public:
    CCard();
    CCard(SUIT suit, int value);
private:
    SUIT mSuit;
    int mValue;
};

#include "CCard.cpp"
Reply With Quote
  #2 (permalink)  
Old September 12th, 2004, 11:21 PM
Authorized User
 
Join Date: Apr 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Antony
Default

mSuit and mValue are private in your class definition make it public. and move the enum declarations to the cpp file. hope this helps.

Antony
Reply With Quote
  #3 (permalink)  
Old September 13th, 2004, 09:31 AM
Authorized User
 
Join Date: Aug 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Spivonious
Default

No change if I make the member variables public. Also, I need the enum's defined in the header or else my class definition doesn't know what they are.

I also tried the same files in Visual C++ 6.0 with the same result. Oddly enough it compiles if I don't put the CCard.cpp file in the project.
Reply With Quote
  #4 (permalink)  
Old September 13th, 2004, 10:07 AM
Authorized User
 
Join Date: Aug 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Spivonious
Default

Hallelujah! After much searching through the MSDN Library, I found that I needed to include stdafx.h in CCard.cpp before I included CCard.h.

Reply With Quote
  #5 (permalink)  
Old September 15th, 2004, 02:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Or you can choose not to use precompiled headers in the projects settings.
In projects settings -> C/C++ tab select precompiled headers in the category list and select not using precompiled headers.
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Unexpected end of file while parsing PI... rageypeep .NET Framework 3.5 2 June 20th, 2008 04:18 AM
Unexpected end of file while parsing... anup_daware C# 1 February 7th, 2007 05:14 AM
Parse error: parse error, unexpected $end Ayodeji Adegbaju Pro PHP 3 January 12th, 2007 12:21 PM
unexpected end of file Spivonious Visual C++ 2 September 21st, 2004 07:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.