class MyFloat{ public: MyFloat(float val){m_val = val;} operator float(){return m_val;} protected: float m_val;}; int main(int argc, char **argv){ MyFloat a = 0.5f; MyFloat b = 1.0f; float x = true ? a-0.5f : b; return 0;}
Standard input is empty
prog.cpp: In function ‘int main(int, char**)’: prog.cpp:14:31: error: operands to ?: have different types ‘float’ and ‘MyFloat’ prog.cpp:14:11: warning: unused variable ‘x’ [-Wunused-variable]
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!