Вопрос по c, struct – C Союзы и полиморфизм [дубликаты]

3

Possible Duplicate:
How can I simulate OO-style polymorphism in C?

Error: User Rate Limit Exceeded

typedef struct{
...
...
} A;

typedef struct{
...
... 
} B;

typedef union{
        A a;
        B b;
}C;

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

myMethod(C){
...
}

Error: User Rate Limit Exceeded

main(){
A myA;
myMethod(myA);
}

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded David Heffernan
Error: User Rate Limit Exceeded AFS
Error: User Rate Limit Exceeded user529758
Error: User Rate Limit Exceeded AFS

Ваш Ответ

3   ответа
4

Error: User Rate Limit Exceededtransparent_unionError: User Rate Limit Exceeded

typedef union __attribute__((transparent_union)) {
        A a;
        B b;
} C;

Error: User Rate Limit ExceededAError: User Rate Limit ExceededBError: User Rate Limit ExceededCError: User Rate Limit Exceeded

A foo1;
B foo2;
C foo3;
myMethod(foo1);
myMethod(foo2);
myMethod(foo3);

Error: User Rate Limit ExceededError: User Rate Limit Exceeded.

Error: User Rate Limit Exceeded AFS
Error: User Rate Limit ExceededC[0].a = a;
0

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededmyFunction()Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededmyFunction()Error: User Rate Limit ExceededA, BError: User Rate Limit ExceededCError: User Rate Limit Exceededvoid*Error: User Rate Limit Exceeded

0

Error: User Rate Limit Exceeded

A myA;
myMethod((C) myA);
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded

Похожие вопросы