2018년 9월 27일 목요일

Compiler error C4430: missing type specifier - int assumed [duplicate]

Compiler error C4430: missing type specifier - int assumed [duplicate]


C++ 기초 에러.

I have this error:
"error C4430: missing type specifier - int assumed. Note: C++ does not support default-int"
with this code example :
//A.h    
#include "B.h"
class A{
    B* b;
    ..
};

//B.h
#include "A.h"
class B{ 
    A* a; // error error C4430: missing type specifier - int assumed.
}

This is a circular dependency issue. For declaring a pointer to some class, the definition of the class is not needed; i.e. the type doesn't have to be a complete type. So you don't need to include A.h in B.hforward declaration is enough. Such as:
//B.h
class A; // change the include of A.h to forward declaration
class B { 
    A* a;
};


아마 서로를 참조하고 있어서 함수로 따지면 무한루프? 형식으 에러를 내주는거 같음. ( 내피셜... )

저렇게 사용해야 할 경우 헤더 포함하는것 보단 사용할 클래스만 선언해서 사용해주는게 좋다. ( 헤더에서 선언해줘야 할 경우 )

출처 - https://stackoverflow.com/questions/23283080/compiler-error-c4430-missing-type-specifier-int-assumed

스택오버버플로우

댓글 없음:

댓글 쓰기