2012-09-21 5 views
2

설명하기 어려울 수 있습니다. 저는 MS VisC++ 2010 Express에서 약 1 개월 동안 프로그램을 개발했습니다. 갑자기 많은 수의 .cpp 파일이 .h 파일과 닿지 않는 것처럼 보였습니다. 이상한 문제는 없었습니다. 예를 들어 주 함수에서 내가 만든 주 사용 개체는 갑자기 빨간색 줄이 생기고 구문 오류 "theClass is undefined"이 나타납니다. 이것은 iostream에 적용되므로 갑자기 cout은 정의되지 않습니다. 나는 무슨 일이 일어 났는지 전혀 모른다. 모든 외부 헤더 파일과 라이브러리가 갑자기 IDE에서 사라졌습니다. .cpp 파일에서, 나는 class constructorMS VisC++ 2010 express : 갑자기 프로젝트에 더 이상 헤더 파일이 보이지 않습니다.

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

내가 클래스 이름 aPokerGame 아래 라인을 얻을이 오류가 "must be a class or a namespace name"입니다 선언 할 때. .h 파일이 사라진다면 어떻게 될까요? 실제로 모든 파일이이 문제를 가지고있는 것은 아닙니다. 일부 파일 만이 .cpp입니다. 다른 사람은 ".이 모든 오류가 한 번에 나타났다.

이 헤더 파일이 잘 보인다. 비록 그들 중 하나가"std::basic_ostream<wchar... "디폴트 생성자는 클래스에 존재하지 않는다"처럼 정말 이상한 오류가 Private: "제목"는 아래 "Error: expected a declaration을 .! 아마

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'

+2

아마도 클래스 정의 이후에 세미콜론이 누락되었을 수도 있습니다. 헤더 파일에 세미콜론이 누락되었을 수 있습니다. 표준 헤더 파일 위에 여러 파일을 포함 시키면 컴파일러가 모든 것을 엉망으로 만듭니다. 오류가있는 오류는 줄을 따라 한 가지 방법을 잊어 버렸기 때문에 발생합니다. 각 헤더 파일의 구문을 세세하게 점검하고 괄호 또는 괄호가 일치하지 않는지 확인하고 필요한 곳에 세미콜론이 있는지 확인하십시오. –

+0

Thanks Seth :) 모든 .h 파일을 처리하려고하고 때로는 파일을 저장하는 경우가 있습니다. 한가지, 그러나 어떻게 iostream이 메인에서 차단 될 수 있습니까? cout은 메인 클래스에서 정의되지 않았습니다. 이 빌드 오류와 관련된 작업 : "1> c : \ program files (x86) \ microsoft Visual Studio 10.0 \ vc \ include \ iostream (10) : 오류 C2059 : 구문 오류 : 'namespace'" – user442920

+0

그래, 문제가 해결되었습니다. Seth에게 다시 한 번 감사드립니다. 정확히 당신이 제안한 것처럼, .h 파일에서 braket과 세미콜론이 누락되었습니다. 그것은 심장 마비였습니다. – user442920

답변

7

당신이 클래스 definiti 후 세미콜론 누락 :

이 도와주세요 개인 회원 여기

은 컴파일 오류의 예입니다 위에 또는 당신이 #include 같은 헤더 파일에 그저 뭔가 다른 표준 파일을 위의 다른 파일의 무리에 모든 엉망이 컴파일러가 오류가 오류로만보고하기 때문에 당신이 줄을 좀 잊어 버렸기 때문에 .

각 헤더 파일의 구문을 세밀하게 확인하고 불일치하는 괄호 또는 중괄호를 찾고 필요한 곳에 세미콜론이 있는지 확인하십시오.

관련 문제