2012-08-15 2 views
2

그래서 C++로 텍스트 기반 게임을 만들려고합니다. Visual Studio 2010을 사용하고 있습니다. 다음은 내가 생각하는 일부 코드 블록입니다. 더 이상 필요하면 저에게 물어 보는 것을 주저하지 마십시오.오류 C2065 : '아무데도': 선언되지 않은 식별자

장소라는 게임에 대한 클래스를 만들려고합니다. 나는 장소를 만들고 그것의 북쪽, 남쪽, 동쪽, 그리고 서쪽에 또 하나의 "장소"를 가지고있다. 나는 지금 당장 혼란스러워. 나는이 물건에 멍청 아. 나는 무언가를 조사하고 있을지도 모른다.

//places.h------------------------ 
#include "place.h" 

//Nowhere place 
string nowheredescr = "A strange hole to nowhere"; 
place nowhere(&nowheredescr, &nowhere, &nowhere, &nowhere, &nowhere); //Error occurs here 
// 

//place.h------------------------ 
#ifndef place_h 
#define place_h 

#include "classes.h" 

class place 
{ 
public: 
    place(string *Sdescription, place *Snorth, place *Ssouth, place *Swest, place *Seast); 
    ~place(void); 
private: 
    string *description; 
    place *north; 
    place *south; 
    place *east; 
    place *west; 
}; 

#endif 

//place.cpp------------------- 
#include "place.h" 
#include <iostream> 


place::place(string *Sdescription, place *Snorth, place *Ssouth, place *Swest, place *Seast) 
{ 
    description = Sdescription; 
    north = Snorth; 
    south = Ssouth; 
    west = Swest; 
    east = Seast; 
} 


place::~place(void) 
{ 
} 
+0

@ dasblinkenlight 님의 제안으로 업데이트되었습니다. – superzilla

+0

@ dasblinkenlight 나는이 4 번 : "1> c : \ 사용자 \ jackson \ google 드라이브 \ public \ C++ projects \ parabellum \ parabellum \ places.cpp (5) : C2065 오류 : '아무데도 : 알 수없는 식별자" 그리고 어떤 이유로 귀하의 답변이 삭제되었습니다. – superzilla

답변

2

다음 구문은 3.3.1/1

이름에 대한 선언의 포인트는 바로입니다 오류 C++ 03 표준에 설명

place nowhere = place(&nowheredescr, &nowhere, &nowhere, &nowhere, &nowhere); 

를 해결 것 완료자인 선언 자 (8 절)와 이니셜 라이저 (있는 경우)보다 앞에

OP 예제에서 place nowhere(.....)은 선언자를 나타내므로 생성자 매개 변수로 사용되는 nowhere은 선언되지 않은 것으로 간주됩니다. 예제에서 place nowhere은 선언자이고 place(.....)은 이니셜 라이저이므로 해당 시점에 nowhere이 선언됩니다.

관련 문제