순환 선언에 문제가 있습니다. 그러나 지금까지 발견 된 모든 해결책으로는 문제가 직접 해결되지 않습니다. 여기 C++ Circular Declaration Issues
일부 코드 :Transformable.h
#pragma once
#include "TransformMatrix.h"
class Transformable {
public:
TransformMatrix Transform;
virtual void transform_callback();
};
TransformMatrix.h
#pragma once
#include "Transformable.h"
class Transformable;
class TransformMatrix {
private:
Transformable *callback_object;
public:
TransformMatrix();
TransformMatrix(Transformable *cb_object);
Transforms.h
#pragma once
#include "Transformable.h"
#include "TransformMatrix.h"
A.h
class A: public Transformable {
public:
A();
/* We want a callback */
TransformMatrix Transform = TransformMatrix(this);
나는 기본 클래스를 구현하고, 그래서 두 개의 파일마다 포함 할 필요가 없습니다 특별한 헤더를 사용하는 클래스가 있습니다. 그러나 내가 오류는 다음과 같습니다
Transformable.h (7) : 오류 C3646 : '변환': 알 수없는 재정
Transformable.h (7) : 오류 C4430 : 형식 지정자가 누락 - 가정 int 치. 참고 : C++은 default-int를 지원하지 않습니다.
TransformMatrix.h 파일에서 #include "Transformable.h"지시문을 제거해야합니다. –
나는 또한 이것을 얻으려고했다 : '1> TransformMatrix.cpp (141) : 오류 C2027 : 정의되지 않은 유형 'Transformable'의 사용 1> TransformMatrix.h (8) : 참고 : 'Transformable' 1> TransformMatrix.cpp (141) : 오류 C2227 : 왼쪽의 '-> transform_callback'이 클래스/구조체/공용체/제네릭 유형을 가리켜 야합니다. –
TransformMatrix.cpp 파일에 #include "Transformable.h"를 추가해야하는 것처럼 들립니다. –