Call of sdut 3-3 Constructor (advanced), sdut3-3

Source: Internet
Author: User

Call of sdut 3-3 Constructor (advanced), sdut3-3

3-3 calling Constructor (advanced) Time Limit: 1000 MS Memory limit: 65536 K Description

Through this exercise, you can learn the time to call constructor and destructor when creating common objects, object arrays, and dynamic creation and destructor;

A Class A must be created. The class only contains constructor and destructor. The class definition and main code of the main function are written according to the program output.

Input

None

Output

The output contains 11 rows of data, as shown in the sample output.

Sample Input
None
Sample output
----begin main---constructing an object of Aconstructing an object of ADestructing an object of A*******constructing an object of Aconstructing an object of A----end main---Destructing an object of ADestructing an object of ADestructing an object of A
Sample program from Huang Jingjing

# Include <iostream> using namespace std; class A {public: A () // constructor {cout <"constructing an object of A" <endl ;}~ A () // destructor {cout <"Destructing an object of A" <endl ;}}; int main () {cout <"---- begin main ---" <endl; A a; A * B; // defines A pointer variable B = new A pointing to A class object; // delete B is the initial address of the new object in B; // release the memory space cout pointed to by B <"********" <endl; A c; A d; cout <"---- end main ---" <endl; return 0 ;}





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.