Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
point to a rvalue
//g++ 5.4.0 #include <iostream> using namespace std; class Test{ int* ptr; public: void setValue(int& value){ ptr = &value; // warring : value may be a rvalue } int getValue(){ return *ptr; } }; int main() { int a = 100; Test testA; testA.setValue(a); cout<< testA.getValue() <<endl; // 100 Test testB; { int tmp = 200; // tmp is a local variable of this scope testB.setValue(tmp); cout<< testB.getValue() <<endl; // 200 }// out of this scope ,tmp be deconstruct cout<< testB.getValue() <<endl; // ??? }
run
|
edit
|
history
|
help
0
RegexSearch
K edit distance
Parser + Str2Int
InverseMatrix2n2
ASHA
MinCostKStops_BFS
random
barai_1
map::swap()_30-Seconds-of-C++
Expected types