Skip to content

Instantly share code, notes, and snippets.

@DamonHao
Created July 21, 2014 15:02
Show Gist options
  • Select an option

  • Save DamonHao/25c922cf930e4cf0913b to your computer and use it in GitHub Desktop.

Select an option

Save DamonHao/25c922cf930e4cf0913b to your computer and use it in GitHub Desktop.
different case of function reutrn value
#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