Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Created July 14, 2017 00:27
Show Gist options
  • Save kaityo256/a334a15d4999d91ba7ff96af04f3dbcb to your computer and use it in GitHub Desktop.
Save kaityo256/a334a15d4999d91ba7ff96af04f3dbcb to your computer and use it in GitHub Desktop.
A sample using ternary operators
#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