The same overloaded operator allows you to construct objects of class A, B, and C in shared memory.
同一个重载的操作符让您可以在共享内存中构造类 A、B 和 C 的对象。
Short answer: no, at least not in C. You can construct such constructs in other languages and in theory even c.
简单回答:没有,至少在C语言里是没有的,你可以,在C语言或其他语言中创建这样一个结构体。
Languages such as C# have added the "using" construct, which helps the latter two problems, but again for nontrivial cases it is complex and error prone.
诸如 C# 等语言添加了“using”构造,它有助于解决后面两个问题,但对于特殊情况,它也会很复杂且容易出错。
Short answer: no, at least not in C. You can construct such constructs in other languages and in theory even C.
简单回答:没有,至少在C语言里是没有的,你可以,在C语言或其他语言中创建这样一个结构体。
Here, too, gets a little ugly and this is why I tend not to like this construct, at least in C, but sometimes it's necessary or it's the simplest way to achieve this goal.
这里也有点难看的,这也是为什么我,不太喜欢这个结构,至少在C语言中,但是有时它是必须的,或者它是达到目标最简单的方法。
So turns out C supports what's called a switch, a switching construct.
所以C语言支持叫做switch的东西,一个开关结构。
应用推荐