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