typedef struct s * node;
typedef struct s
{
int a;
int b;
} s;
class cls
{
public :
int c;
int d;
int testB(void);
};
int testF(cls * aCls);
int testB(void);
int main(void)
{
node sStruct = NULL;
sStruct = (node) malloc(sizeof(s));
sStruct->a = 1;
sStruct->b = 2;
printf("nstruct : %d, %dn",sStruct->a, sStruct->b);
testF((cls *)sStruct);
free(sStruct);
return 0;
}
int testF(cls * aCls)
{
printf("nclass : %d, %dn",aCls->c, aCls->d);
return 0;
}
int testB(void)
{
}
대충 위처럼 테스트 코드를 만들어보니 캐스팅이 무리없이 됩니다.
그렇다면 struct->class로의 캐스팅도 잘 될것 같은데요.
class내에 메소드가 있음에도 무시하고 멤버변수만 타입이 같으면 캐스팅이 되는건가요?
아니면 컴파일러따라 다를까요?
private이면 안될것 같네요.