C + + NetEase cloud Classroom Development Engineer-header file and class declaration

Source: Internet
Author: User
Tags class definition

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

Related Article

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.