Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

overriding - Is it possible to overload operators in C?

Is it possible to overload operators (such as operators of comparison) in 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.

Anyone have any ideas?

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.

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. (:

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

No, it is not possible. C does not support operator overloading by the developer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...