Created
January 6, 2018 00:36
-
-
Save puremourning/b2123b8760cecbaf3c2e09776390620f to your computer and use it in GitHub Desktop.
copy reference
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
// Example program | |
#include <iostream> | |
#include <string> | |
struct nocopy { | |
nocopy(int i_) : i(i_) {} | |
nocopy( const nocopy& ) = delete; | |
int i; | |
}; | |
struct test { | |
test( nocopy& n_ ) : n( n_ ) {} | |
test( const test& other ): n(other.n) {} | |
nocopy& n; | |
}; | |
int main() | |
{ | |
nocopy n{ 1 }; | |
test t{ n }; | |
test t1{ t }; | |
std::cout << "I: " << t1.n.i << '\n'; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment