Class-Differentiated classifications have two classics, 1 contain pointers (complex), and 2 do not contain pointers (string).
1.complex
The class is divided into: the data member part (the size of the data member in memory, the data may be many copies) and the function part ( only one copy ).
2.string
Class: Contains only one pointer ( which is understood here as a pointer to a data member), and the size of each data member created actually contains only one pointer.
3.c++ Programs Code Basic form
. h (header files) Classes Declaration (statement)
. CPP ()
The. h () standard library, which introduces the standard library in the form of angle brackets.
4. defensive declarations (so that the order of included include is unaffected)
#ifndef _complex_
#define _complex_
#endif
5. Layout of header Files
#ifndef _complex_
#define _COMPLEX_ Defense Statement
----------------------------------------------------------------------
#include <cmath>
Class Ostream;
Class complex;
complex& _DOAPL (complex* ths, const complex& R); front-facing declaration
----------------------------------------------------------------------
Class complex{ Declaration
....
};
----------------------------------------------------------------------
Complex::function ... class definition
Declaration of the 6.class (declaration)
introduction of template<typename t> template
Class complex{ class head
Public
Complex (T r = 0, t i = 0): Re (r), Im (r) {}
complex& operator + = (const complex&);
T Real () const {return re;}
T imag () const {return im;}
Private
T Re, im;
Friend complex& _DOAPL (complex*, const complex&);
};
-------------------------------------------------------------------------
{
Complex<double> C1 (2.5,1.5);
complex<int> C2 (2,6);
}
C + + NetEase cloud Classroom Development Engineer-header file and class declaration