struct mercadoria {
int peso_item;
float preco_kilo;
float (*pf)(void);
};
typedef struct mercadoria2 pm;
struct mercadoria2 {
int peso_item;
float preco_kilo;
int (*pf)(pm);
};
float preco(){
return 1.0;
}
int preco2(pm x){
return x.peso_item;
}
int main(){
struct mercadoria x[2] = { { 10,2.3,preco}, { 10,2.3,preco}};
pm y[2] = {{3,2.3, preco2}, {3,2.3, preco2}};
pm z = { 5,2.3,preco2};
printf("%d\n",y[0].pf(y[0]));
printf("%d\n",z.pf(z));
return 0;
}
Sim
No comments:
Post a Comment