Invocation of the constructor function

Source: Internet
Author: User

1#include <iostream>2#include <cstring>3 using namespacestd;4 class Person5 {6     Static Constunsigned LIMIT = -;//forgot to add unsigned.7     stringlname;8     CharFname[limit];9      Public:Ten  One Person () A             { -LName =""; -fname[0] =' /'; the             }; -Person (Const stringlnConst Char*FN ="heyyou"); -             voidShow ()Const -             { +cout << fname <<' '<< lname <<Endl; -             }; +             voidFormalshow ()Const A             { atcout << lname <<", "<< fname <<Endl;  -             }; - /*Person (const string LN, const char *FN) -             { - lname = ln; - strcpy (FNAME,FN); in             } - */ to //can not use the above paragraph, there will be overloaded, put it to the letter number of the head plus classname:: Just fine + }; -Person::P Erson (Const stringlnConst Char*fn) the     { *LName =Ln; $ strcpy (FNAME,FN);Panax Notoginseng     } -  the intMain () + { A Person one ; thePerson ("Smythecraft"); +Person Three ("Dimwiddy","Sam"); - One . Show (); $ One . Formalshow (); $cout<<Endl; -      - Both . Show (); the Both . Formalshow (); -cout<<Endl;Wuyi      the three. Show (); - three. Formalshow (); Wucout<<Endl; -}

A different constructor is selected for one two three.

Invocation of the constructor function

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.