问题描述
是否有可能超载运营商(如比较运营商)用C?
Is it possible to overload operators (such as operators of comparison) in C?
如果是这样,你怎么办呢?我做了快速搜索,但我发现是C ++,和我要的是对C
If so, how do you do it? I did a quick search, but all I found was for C++, and what I want is for C.
任何人有什么想法?
EDIT1:我们的想法是:我有一个结构,我需要做一个比较(基于该结构的成员)。而对于这一点,我想运营商相比,我的新的数据类型相关联。
The idea is: I have a struct, and I need to do a comparison (based on a member of the struct). And for this I would like to associate operators compared to my new "data type".
EDIT2:我完全意识到,我可以在不使用操作符重载的事,但不知道如果你能做到这一点具有过载
I am completely aware that I can do without the use of operator overloading, but was wondering if you can do this WITH OVERLOAD.
答:过载的概念与面向对象编程有关。因为C不是面向对象的,因此不能含有过载的概念。 (:
Answer: The concept of overload is associated with object-oriented programming. Since C is not object oriented and therefore can not contain a concept of overload. (:
推荐答案
没有,那是不可能的。 C不支持运算符重载。
No, it is not possible. C does not support operator overloading.
这篇关于是否有可能超负荷运营商C 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!