Passing variable type as function parameter

后端 未结 4 2040
孤独总比滥情好
孤独总比滥情好 2020-12-24 12:03

Is it possible to pass variable type as part of a function parameter, e.g.:

void foo(varType type)
{
  // Cast to global static
  unsigned char bar;
  bar =          


        
4条回答
  •  长情又很酷
    2020-12-24 12:23

    I don't see how you could do this in the general case, given that C is a statically typed language.

    The compiler needs to know at compile time what the type of type * is in order to be able to generate the reference to ->member.

提交回复
热议问题