Created
September 10, 2015 22:58
-
-
Save theodoregoetz/bae909c3b98c247dc530 to your computer and use it in GitHub Desktop.
C++ Constructor with rvalue
This file contains 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 <iostream> | |
struct Foo | |
{ | |
public: | |
Foo(int d) : x(d) {} | |
int x; | |
}; | |
int main() | |
{ | |
double x = 3.14; | |
Foo f( int(x) ); // does not compile! | |
//Foo f( (int) x ); // OK | |
std::cout << f.x << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment