1#include <iostream>2 using namespacestd;3 classTest4 {5 int*i;6 7 Public:8TestintN) {i =New int[n];}9 voidFuncintN) {test a (n); A.F (); cout <<Endl;}Ten voidF () {cout<< This<<Endl;} One voidShit (Test x) {x.i =i;} A~test () {cout << This<<"was deconstructed."<<Endl;} - }; - voidMain () the { -Test B (3); -cout <<"b"; B.f (); -cout <<"B Medium a"; B.func (5); +Test C (6); -cout <<"C"; c.f (); +cout <<"C in a"; C.func (5); A B.shit (c); at}
1#include <iostream>2 using namespacestd;3 classTest4 {5 int*i;6 7 Public:8TestintN) {i =New int[n];}9 voidFuncintN) {test a (n); A.F (); cout <<Endl;}Ten voidF () {cout<< This<<Endl;} One voidShit (Test x) {x.i =i;} A~test () {cout << This<<"was deconstructed."<<Endl;} - }; - voidMain () the { -Test B (3); -cout <<"b"; B.f (); - //cout << "B in a"; B.func (5); +Test C (6); -cout <<"C"; c.f (); + //cout << "C in a"; C.func (5); A B.shit (c); at}
The process-oriented neutron function is declared first, whether or not it is called? The functions in the class are declared at the time of program build (the statement inside the function body does not have a build and is called). So
Even if you do not call member functions in a class other than constructs and destructors. If there are member functions in these functions that have the object of a class as a parameter (not a reference, a reference is not an object),
The little thing about the destruction of C + + (Personal spit groove to