Constructors classification
Parametric points: the reference structure constructor with no arguments
By type: constructor and copy constructor
Three kinds of method invocation
1. Display Method
2. bracketing
3.'s implicit conversion method
. 1 #include <bits / STDC ++ H.> 2 the using namespace STD; . 3 . 4 class STU . 5 { . 6 public : . 7 STU () . 8 { . 9 the puts ( " STU no argument constructor calls " ); 10 } . 11 12 is STU ( int Age) 13 is { 14 s_age = Age; 15 the puts ( " STU has argument constructor calls " ); 16 } . 17 18 is STU ( const STU & S) . 19 { 20 is // all the property of the incoming copy all students to me 21 is s_age = s.s_age; 22 is the puts ( " STU copy constructor calls " ); 23 } 24 ~ STU () 25 { 26 is the puts ( " STU destructor calls " ); 27 } 28 int s_age; 29 }; 30 // call 31 is void Test () 32 { 33 // bracketing 34 is // STU S; // default constructor call 35 // STU S2 (10); // with a reference constructor calls 36 // STU S3 (S2); // copy constructor call 37 // Note that the default configuration not to add (), otherwise the system will be considered a function declaration 38 is 39 // display method 40 STU S; 41 is STU STU S2 = ( 18 is ); // with a reference structure 42 is STU STU S3 = ( S2); // copy constructor 43 is // 44 is // STU (10); // not the object name, the object is called anonymous 45 // Characteristics: After the current execution line, the system immediately recovered anonymous object 46 is // COUT << "hahahha" << endl; 47 // implicit conversion method's 48 STU S4 = 10 ; // with a call reference 49 STU S5 S4 =; // copy constructor call 50 51 is } 52 is 53 is int main () 54 is { 55 Test (); 56 is return 0 ; 57 is }