Created
July 21, 2014 15:02
-
-
Save DamonHao/25c922cf930e4cf0913b to your computer and use it in GitHub Desktop.
different case of function reutrn value
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 <iostream> | |
| using namespace std; | |
| struct A | |
| { | |
| int a; | |
| int b; | |
| int c; | |
| }; | |
| A func() | |
| { | |
| A tmp; | |
| tmp.a = 1; | |
| tmp.b = 2; | |
| tmp.c = 3; | |
| return tmp; | |
| } | |
| int fun2() | |
| { | |
| int i = 0; | |
| return i; | |
| } | |
| int main() | |
| { | |
| A tmp; | |
| tmp.a = 4; | |
| tmp.b = 5; | |
| tmp.c = 6; | |
| cout << (func() = tmp).c << endl; | |
| //fun2() = 10; //Error lvalue required as left operand of assignment | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment