[Notctions] Effective C ++ 12 (replaced by INITIALIZATION)

xiaoxiao2021-03-06  16

#include

#include

Using namespace std;

//

/ / Since the Class has Point Member, so we cannot use AliaSing in Assignment and Copy actions (alias)

// So you will want to implement these functions, you should

//

// We have two ways, the first MEMBER INITIALZATION LIST, as const, and Reference Merber can only be initially

// Impellation; if if IF does not change its members, we should declare them to const; in this case, we can only use init list.

/ / With the init list, even if there is no const, INIT LIST is better than the assignment within the Constructor, the reason is to use the init list, only

// A String Copy Construtor called, there is a CONSTRUCT, an assocignment,

// String class is very small, for some large classes, this call is a big cost,

//

/ / There is also a benefit, this form has a great advantage to future maintenance, no need to go to the constructor's implementation function

//modify,

//

/ / However, when you have a lot of build types, there is a fact that the built-in type Non-const and Non-Reference objects have no differences in INIT and ASSI.

/ / You can write into init () {a = b = c = 1, d = E = f = 2;} It does not have user-defined types of those ASSI issues,

//

// There is also a question to never be initially in Constuctor, a Static object should only be initially once in the program; at least

//effectiveness;

//

Template

Class nameptr {

PUBLIC:

Nameptr (const string & initname, t * init): name (initname), PTR (Initptr) {}

// {

// name = initname;

// ptr = initptr;

//}

Private:

String nmae;

T * PTR;

}

Void main () {

;

}

转载请注明原文地址:https://www.9cbs.com/read-44846.html

New Post(0)