user442920
user442920

Reputation: 847

MS VisC++ 2010 express: Suddenly Project no longer sees header files

This may be hard to explain. I have been developing a program for about a month now in MS VisC++ 2010 express. I have had no strange problems and was ready to build my project for the 100th time when suddenly, many of the .cpp files seemed to loose contact with the .h files. For instance, in the main function, objects that I had created and used weeks ago, suddenly got the red line under them and the syntax error "theClass is undefined". This applies to iostream, so suddenly cout is undefined. I have no idea what happened. One second to another all external header files and libraries suddenly disappeared in the eyes of the IDE. In the .cpp files, when I declare the class constructor

//initializes a poker game
aPokerGame::aPokerGame(void)
{
    stopPlaying = 'n';          
}

I get the line under the class name aPokerGame and this error is "must be a class or a namespace name". Isn't this what would be happen if the .h files disappeared? In fact, not all .cpp files are having this problem, only some. Others have really weird errors in them like "no default constructor exists for class"std::basic_ostream<wchar...". All these errors appeared at once.

The header files seem fine. Though one of them has "Error: expected a declaration" under the "Private:" heading for the private members.

Please help!

Here is a sample of the compile errors:

1>------ Build started: Project: firstProj, Configuration: Debug Win32 ------ 1> userPlayer.cpp 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.h(9): error C2504: 'Player' : base class undefined 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\iostream(10): error C2059: syntax error : 'namespace' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\iostream(10): error C2334: unexpected token(s) preceding '{'; skipping apparent function body 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.cpp(8): error C3254: 'Player' : class contains explicit override '{ctor}' but does not derive from an interface that contains the function declaration 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.cpp(8): error C2838: '{ctor}' : illegal qualified name in member declaration 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.cpp(8): error C2535: 'Player::Player(void)' : member function already defined or declared 1>
c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\player.h(18) : see declaration of 'Player::Player' 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.cpp(13): error C3254: 'Player' : class contains explicit override '{dtor}' but does not derive from an interface that contains the function declaration 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.cpp(13): error C2838: '{dtor}' : illegal qualified name in member declaration 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.cpp(13): error C2535: 'Player::~Player(void)' : member function already defined or declared 1>
c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\player.h(19) : see declaration of 'Player::~Player' 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.cpp(18): error C3254: 'Player' : class contains explicit override 'userBets' but does not derive from an interface that contains the function declaration 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.cpp(18): error C2838: 'userBets' : illegal qualified name in member declaration 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.cpp(38): fatal error C1075: end of file found before the left brace '{' at 'c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\player.h(12)' was matched 1> pokerRound.cpp 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\npcplayer.h(9): error C2504: 'Player' : base class undefined 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\userplayer.h(9): error C2504: 'Player' : base class undefined 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\iostream(10): error C2059: syntax error : 'namespace' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\iostream(10): error C2334: unexpected token(s) preceding '{'; skipping apparent function body 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\time.h(35): error C2059: syntax error : 'string' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\time.h(35): error C2334: unexpected token(s) preceding '{'; skipping apparent function body 1>c:\users\bn\dropbox\myprojects\mysoftware\c++\firstproj\firstproj\pokerround.cpp(16): error C2059: syntax error : 'namespace'

Upvotes: 2

Views: 1445

Answers (1)

Seth Carnegie
Seth Carnegie

Reputation: 75130

Probably you are missing a semicolon after a class definition or something like that in a header file which you #include into a bunch of other files above some standard header files, which makes everything mess up and the compiler report things as errors that are only errors because you forgot one little thing way up the line.

Double check the syntax of each of your header files meticulously, looking for mismatching parentheses or braces, and making sure you have semicolons where they are needed.

Upvotes: 7

Related Questions