The little thing about the destruction of C + + (Personal spit groove to

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.