Created
July 14, 2017 00:27
-
-
Save kaityo256/a334a15d4999d91ba7ff96af04f3dbcb to your computer and use it in GitHub Desktop.
A sample using ternary operators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| struct Hoge{ | |
| Hoge(int a){ | |
| printf("int %d\n",a); | |
| } | |
| Hoge(double d){ | |
| printf("double %f\n",d); | |
| } | |
| }; | |
| int | |
| main(void){ | |
| int a = 2, b = 1; | |
| Hoge h1(1); // => int 1 | |
| Hoge h2(2.0); // => double 2.000000 | |
| Hoge h3(a > b? 1 : 2.0); //=> double 1.000000 (Why?) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment