내가 포함하는 것과 관련해서 뭔가 잘못하고있는 것 같지만 잘못되었다고 생각하는 것만 같습니다. 나는 w7 64 비트 시스템에서 Visual Studio 10을 사용하고 있습니다.C++ 오류 : 개체를 만들려고 할 때 "선언되지 않은 식별자"입니다. 헤더 문제?
컴파일 오류가 나는 얻을 :
testd.cpp(9): warning C4018: '<' : signed/unsigned mismatch
testd.cpp(21): warning C4018: '<' : signed/unsigned mismatch
testd.cpp(36): error C2065: 'tmp' : undeclared identifier
testd.cpp(37): error C2065: 'tmp' : undeclared identifier
testd.cpp(37): error C2227: left of '->getTestId' must point to class/struct/union/generic type
type is ''unknown-type''
testd.cpp(40): error C2065: 'tmp' : undeclared identifier
testd.cpp(41): error C2065: 'tmp' : undeclared identifier
그래서 나는 새로운 객체 (TMP)을 만들려고 노력하고 있어요 때마다, 그는 "선언되지 않은 식별자"말했다. 내 생각에 그는 테스트의 클래스 정의 (그는 나를 경고하지 않습니다), 을 얻을 수 없다는 것이지만, 왜 그런지는 모르겠다. 최소한 코드를 줄여서 오류 기능이 남아 있습니다. 시간에 미리 감사드립니다
test.h : 2 부가 요소, 게터, 세터, 생성자와 클래스 테스트 및 소멸자의 정의
#pragma once
class Test
{
private:
int myTestId;
string myTestNaam;
public:
Test();
Test(string TestNaam,int TestId);
~Test();
int getTestId();
string getTestNaam();
void setTestId(int TestId);
};
* Test.cpp에 : 함수의 정의 클래스 테스트
#include "stdafx.h"
#include "headers/Test.h"
Test::Test() {setTestId(0);}
Test::Test(string TestNaam, int TestId) {setTestId(TestId);}
Test::~Test() {}
void Test::setTestId(int TestId) {myTestId=TestId;}
int Test::getTestId() {return myTestId;}
testd.h 정적 벡터 Testd 클래스의 정의 및 정지 기능
#pragma once
#include "Test.h"
class TestD
{
private:
static vector<Test*> Testen;
static int getPosition(int ID);
public:
static Test* newTest(Test*);
static Test* getTest(int ID);
};
는 testd.cpp : 클래스의 기능을 정의 Testd
#include "StdAfx.h"
#include "headers/Test.h"
#include "headers/Testd.h"
vector<Test*> TestD::Testen = vector<Test*>();
Test* TestD::getTest(int ID)
{for(int i =0; i < Testen.size(); i++)
{Test* tmp = Testen.at(i);
if(tmp->getTestId() == ID)
return tmp;
}
return 0;
}
int TestD::getPosition(int ID)
{for(int i = 0; i < Testen.size(); i++)
{Test* tmp = Testen.at(i);
if(tmp->getTestId() == ID)
return i;
}
return -1;
}
Test* TestD::newTest(Test* Test)
{if(Test->getTestId()==-1)
{Test* tmp = Testen.at(Testen.size()-1);
int newId = tmp->getTestId()+1;
Test->setTestId(newId);
}
Test* tmp = getTest(Test->getTestId());
if(tmp==0)
{Testen.push_back(Test);
return Test;
}
}
마지막으로 나는 당신의 도움에 대한 내 Stdafx.h에이
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
//some includes are not used in the files I mentioned here, but other files need them
감사를 포함하고 나는하지 않았다 희망 내 가난한 영어로 너를 불쾌하게해라. 시작하려면
btw : "Testen.size()"함수가 int_t (부호가있는)를 반환하기 때문에 "signed/unsigned mismatch"오류가 있다는 것을 알고 있습니다. 그래서 그 오류는 지금 내 문제가되지 않습니다. – Rps
나는이 * 종류의 오류 메시지가 C++에서 가장 문제가되기를 바랍니다. – ulidtko