// strlen
// int length = strlen(src_str);// // char* buffer = new char[length + 1];strcpy(buffer, src_str); //new . , new . , , . new ( 0). new :
char* newstr;
size_t length = 4;newstr = new (std::nothrow) char[length];if (newstr == NULL) { // // }//. . , ++ . , , . . , .
.
delete. . , , , new, - .
, .. , "" . . -, , . , , 99 100 . , - , , .
. , - . ,
. , , , -, , -, , , , , ( delete new, ..).
(, ++ ), , . .
|
|
1. , . , .
2. . - ( ), .
3. , , .
4. (Purify Rational, Bounce Checker Nu-Mega ..)
. - ,
Complex x;x
Complex& y = x;
x y .
x.real = 1;
x.imaginary = 2;y.real 1 y.imaginary 2. , ( & -- ), , .
-, , , , .
int& xref;
int& xref = x;
-, , .. . xref
xref = y;
y , xref. xref - x. :
int x = 10;
int y = 20;int& xref = x;xref = y;x += 2;cout << "x = " << x << endl;cout << "y = " << y << endl;cout << "xref = " << xref << endl;:
x = 22
y = 20xref = 22-, . , , ->, ".".
Complex a;
Complex* aptr = &a;Complex& aref = a;aptr->real = 1;aref.imaginary = 2;, . - , - .