Is operator overloading for classes and structs always resolved at compile-time?
2 Answers 2
Yes, always.
answered Nov 2, 2010 at 12:20
Svisstack
16.7k8 gold badges70 silver badges101 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Lort
I wondered because apparently it isn't in Delphi, because there are speed differences
Björn Pollex
@Lort: This sort of information should be part of your question.
Yes. Only dynamic type-specific behavior achievable in C++ is through virtual member functions.
answered Nov 2, 2010 at 12:21
nakiya
14.5k24 gold badges87 silver badges120 bronze badges
2 Comments
Steve Jessop
And note that operator overloads can be virtual member functions. The overload is still resolved at compile-time, though, so the answer is correct. It's the override which is dynamic.
Dan
@Steve - nice distinction & explanation.
lang-cpp