Run Code
|
Code Wall
|
Users
|
Misc
|
Feedback
|
About
|
Login
|
Theme
amusing overload choice
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86 #include <iostream> struct MyClass { MyClass() : mStr("I'm a string") {} inline operator int() const { return 5; } inline operator const char*() const { return mStr.c_str(); } protected: std::string mStr; }; void myfunc() { MyClass c; std::cout << c << std::endl; } int main() { std::cout << "Hello, world!\n"; myfunc(); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
bad_cast
sinem çalışma
ADL of operator expression & unqualified function call
no-thread
VC++
dynamic_cast in assert Causing Error
post_decrement_example
operator new / delete
Computing the factorial of an integer using factorial and iteration
karma legacy "variant" with attr_cast
Please log in to post a comment.