1 class Foo{
2
3 };
4
5 Foo func1(){
6 Foo f;
7 return f;
8 }
9
10 int func2(){
11 int a = 2;
12 return a;
13 }
14
15 int main(int argc, char** argv){
16 Foo var1;
17 func1() = var1; //OK
18 func2() = 1; //error: expression is not assignable
19 return 0;
20 }
What is the fundamental reason that assignment to the return value that is of built-in type is not allowed but assignment to a return value that is user-defined type is allowed? How is the memory managed that allows one but not the other?
Aucun commentaire:
Enregistrer un commentaire